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

The use of the cancel message is a hack, yeah. But it's what I had to work 
with. We could introduce a new, proper cancellation context to Tasks instead, 
which could be attached to the CancelError when it's raised.

On the topic of multiple cancellations being applied to a task before it gets 
to run: could we just treat the cancellation context as a stack, and when the 
task gets to run, we throw them all in, one by one? Other options would involve 
somehow figuring out what the highest priority cancellation context is, or 
combining all the cancellation contexts into the CancelError somehow.

On the topic of a task getting to run at least once before being cancelled: 
sure, I guess. I've personally never needed this but I can see how it'd be 
useful. Either have a flag on the Task instance or build that logic into the 
cancellation context handling?

----------

_______________________________________
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