-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interoperability with asyncio (part 1) #174
Conversation
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏻
self.assert_poll_call_functions( | ||
output, | ||
["a", "b", "c", "d", "e", "f", "g", "h"], | ||
["d", "h", "e", "f", "g", "a", "b", "c"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update this assertion helper to sort both lists before comparison? Then we don't have to adapt the test if the order changes across Python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it but I thought it would be better to keep it simple and be notified if the order ever changes, sorting could mask other unintended changes, let's keep this for when we know we have a problem, so far the order is the same from 3.8 to 3.12.
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:
async
, this is the only breaking changeIn 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 indispatch.run()
. This a bit hacky and probably not optimal, we could do better by taking a dependency onaiohttp
, 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