Hi,
How can I run my task within an async context manager, httpx.AsyncClient specifically?
I found somewhere an advice to simply pass it as parameter, but it doesn't work
Copy code
import asyncio
from httpx import AsyncClient
from prefect import flow, task
@task
async def fetch(client: AsyncClient):
await client.get('<http://example.com>')
@flow
async def main():
async with AsyncClient() as client:
await fetch(client)
if __name__ == "__main__":
asyncio.run(main())
Flow run encountered an exception. RuntimeError: Event loop is closed
n
Nate
08/18/2024, 11:45 PM
hi @Rafael - what version of prefect are you using?
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.