|
|
|
|
|
by slewis
1221 days ago
|
|
The response here makes me think most commenters don’t have experience with this particular footgun. To clarify: Python can gc your task before it starts, or during its execution if you don’t hold a ref to it yourself. I can’t think of any scenario in which you’d want that behavior, and it is very surprising as a user. Python should hold a ref to tasks until they are complete to prevent this. This also “feels right”, in that if I submit a task to a loop, I’d think the loop would have a ref to the task! It’d be interesting to dig up the internal dev discussions to see why the “fix this” camp hasn’t won. |
|
But I agree that this is unexpected and most code probably isn't ready for being cancelled at random points. (Although I guess in Python your code should be exception safe which is often similar)