dabeaz / curio

Good Curio!
Other
4.02k stars 241 forks source link

Add contextvars support. #254

Closed Fuyukai closed 5 years ago

Fuyukai commented 6 years ago

This adds support for PEP 567 contextvars, by attaching a context object to each Task and making the coroutine inside run within the context.

Problem: contextvars is only in the stdlib in Python 3.7; there is a backport for Python 3.5 and Python 3.6 but I don't know if you want to depend on that (given that curio has no dependencies).

dabeaz commented 6 years ago

Reviewing this. I will probably rely on curio's Activation feature to make a version of this that is optional and doesn't impact code running on Python 3.6.