python-trio / purerpc

Native, async Python gRPC client and server implementation supporting asyncio, uvloop, and trio
Apache License 2.0
217 stars 15 forks source link

Wrap bidirectional streaming requests in context manager #37

Closed VincentVanlaer closed 1 year ago

VincentVanlaer commented 1 year ago

This client API change wraps bidirectional streaming requests in a context manager.

Bidirectional streams need to be able to spawn a task group to keep sending messages from the client to the server while the client is processing one of the messages of the server. In order to prevent corruption of the task group stack, task groups cannot wrap yield statements in generators. This is fixed by creating the task group in a context manager and yielding the generator for the server message from that context manager.

Fixes #36

belm0 commented 1 year ago

I'll rebase to master so that CI runs

VincentVanlaer commented 1 year ago

Should be ready for merging now