3 ms·
Because it's almost always the case that the consumer is going to keep a reference to the task in some way, so that is the logical choice for the "primary owner
by kortex 4y ago
Because it's almost always the case that the consumer is going to keep a reference to the task in some way, so that is the logical choice for the "primary owner" of the task. Python doesn't have ownership per se like rust, but if you keep more than one hard reference to an object around, it'll prevent collection, so in cases such as this it makes sense to designate one primary owner and have all other references be weakref.
- skitter 4y ago> if you keep more than one hard reference to an object around, it'll prevent collection Which is the behavior the parent comment asks for.
- kevin_thibedeau 4y agoThat creates a new problem that you have to remember to kill unwanted threads.
- deleted 4y ago[deleted]
- JonChesterfield 4y agoPython's reference counted - if the event loop holds a reference until the task has run, then drops it, then everything behaves sanely. That's not a cycle. It just means the task that was scheduled will execute, which seems like the right default.