Tin Tvrtković <tinches...@gmail.com> added the comment:

I've essentially forked `async-timeout` (a very good library) into Quattro 
cancel scopes: 
https://github.com/Tinche/quattro/blob/main/src/quattro/cancelscope.py.

The differences are:
* the API follows Trio, so instead of `timeout` you'd use `fail_after` or 
`move_on_after`
* instead of `async with timeout`, you use a normal context manager `with 
fail_after`. The Trio folks think this is important (less suspension points, 
less race conditions) and I agree
* it's somewhat composable (as much as possible under asyncio), each scope 
knows if the CancelError is meant for it or should be propagated further. This 
is implemented by using the CancelError message to carry a nonce. This only 
works on 3.9+, but here that's not a problem
* small deadline adjustment differences, I use a setter on the deadline instead 
of `update` and `shift`
* it's fully type annotated, but so is Andrew's

Let me know if this sounds interesting.

----------
nosy: +tinchester

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46771>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to