Anyone understand #ContextVars in #python ? I'm trying to add support to #svcs so that when there isn't a web framework with a context to glom onto, that you can use the thread/thread.local/ContextVars and an alternative to the Application/Request that a web framework would provide.

So far, I can only get it to "work" if the ContextVars are globals.

https://gist.github.com/matthewdeanmartin/4a4aaa799df7a454b7ddb7230a78a64f#file-thread-py-L21

svcs support for single thread, multiple threads, multiple processes. WIP

svcs support for single thread, multiple threads, multiple processes. WIP - thread.py

Gist

A culmination of a couple of evenings I spent digging into nasty unraisable exceptions related to #contextvars management, printed by the #pytest runner when ran by the #asyncio #grpc server.

https://github.com/grpc/grpc/pull/37240

I wonder, how far can it go? 🤔 When it comes to complicated projects such as gRPC, it's never easy to receive some feedback or negotiate with maintainers. I was also frustrated by the #CLA I needed to sign to deliver the fix.

python: await tasks in grpc.aio.Server.stop() by ikalnytskyi · Pull Request #37240 · grpc/grpc

When grpc.aio.Server.stop(<timeout>) is awaited, it's expected for the server to be graceful shut down. This means that all in-flight requests are finished and clients received their responses, and...

GitHub