interoperability with asyncio (part 2): integration with aiohttp #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on #122, this PR adds a new integration with the
aiohttp
framework, to enable dispatch applications that run onaiohttp
servers, or useaiohttp
clients to integrate with theasyncio
facilities end-to-end.This change is also a prerequisite to more modifications I want to bring to the SDK, that in my mind are other prerequisites for a sync mode where we can wait on dispatch calls in retrieve their results.
Thoughts on next steps
What I would like to get to is an API that matches
asyncio
more closely, for example:This would cause a call to
job
to be dispatched to the scheduler, then waited on by thedispatch.run
event loop, with the result returned.This could also be composed with other
asyncio
operations:This would provide a unified model for both durable and volatile contexts, which would pave the road to simple testing constructs, examples, and integrations with RPC handlers etc...
For blocking world that doesn't use
asyncio
, the.dispatch()
method can still be used, but we'd modify its return value to a form of future-like value where the result can be retrieved in a blocking fashion.Let me know what you think!