dabeaz / curio

Good Curio!
Other
4.05k stars 244 forks source link

FR: contextvars support #310

Closed Andrei-Pozolotin closed 4 years ago

Andrei-Pozolotin commented 4 years ago
  1. there was a failed attempt of contextvars support:

  2. with a promise "to revisit" :-) https://github.com/dabeaz/curio/pull/276#issuecomment-437637540

  3. please revisit

dabeaz commented 4 years ago

Support has just been added in some capacity. It probably needs further testing--especially with threads.

Edit: This is very provisional. Support might be removed if it can't be made to work nicely with threads and other aspects of Curio.

Andrei-Pozolotin commented 4 years ago

thank you. please release

dabeaz commented 4 years ago

I am going to be reverting the prior patch and going in a different direction with this. The main problem is that mutating global state as with contextvars is basically unsound. It also seems to play very poorly with threads which an issue for many Curio features.

I will have something that can work with contextvars if you are so inclined to use that approach and understand its limitations.