dispatchrun / dispatch-py

Python package to develop applications with Dispatch.
https://pypi.org/project/dispatch-py/
Apache License 2.0
56 stars 3 forks source link

interoperability with asyncio (part 1) #174

Closed achille-roussel closed 5 months ago

achille-roussel commented 5 months ago

This PR modifies the dispatch-py internals to build on the asyncio package in order to better integrate with frameworks like FastAPI, httpx, etc... and any other Python code that uses async/await constructs for I/O operations.

A couple of notable changes:

In a few places, we are constructing temporary event loops (using a class similar to asyncio.Runner) to convert from blocking to asyncio code, for example in the http server we use in dispatch.run(). This a bit hacky and probably not optimal, we could do better by taking a dependency on aiohttp, I'll look into it in a follow up PR where I also want to investigate how we could integration the .dispatch() method with asyncio.

Fixes #122