-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in coroutine scheduling. Add ByteStream implementation and si…
…mplify Python symbol visitor. (#1633) * Fix bug in coroutine scheduling. Add ByteStream implementation and simplify Python symbol visitor. * Bug in coroutine scheduling: In the previous iteration, the runtime crate aws-smithy-http-server-python was exposing the python application implementation as a struct, which was wrapped by the codegenerated App to allow to dynamically building the router. This caused scheduling of coroutines (handlers prefixed with async def) to block becuse we were passing the Python eventloop of the parent process that was stored pre-fork(). This commit changes the runtime PyApp to become a trait, allowing us to dynamically build the router post-fork() and with the right event loop. This change also allowed us to remove a bunch of unnecessary Arc(s). * Add ByteStream implementation Implementation of a ByteStream type for Python that can be roughly used like this: let b = await ByteStream.from_path("file.txt") async for chunk in b: print(chunk) Implement futures_core::stream::Stream for Python ByteStream wrapper. The BytesStream implementation in python can now use a sync Mutex from parking_lot because we are now using pyo3_asyncio::tokio::local_future_into_py() to read a chunk, which supports !Send futures. This allows to simply forward the implementation of Stream (poll_next() and size_hint()) directly to our inner SDK ByteStream. * Simplify Python symbol visitor Inherit from Symbol visitor and override just what is needed to swap Python complex types. Signed-off-by: Bigo <[email protected]>
- Loading branch information
Showing
25 changed files
with
718 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.