Message345389
Lukasz, please don't rush. Applied PR makes asyncio more stable, not worse. I see the only way to make it perfect: get rid of weak refs entirely. Otherwise there is always a chance to catch GC run and set element deletion on iteration over the set. Sorry, that's how weakrefs work. There is such possibility: call asyncio._unregister_task() explicitly when the task is done (finished with success or failure or cancelled). By this, we can replace weakset with a regular set. The only requirement is that task should call this _unregister_task() method. No public API change is needed. At the time of work on 3.7, Yuri and I considered this implementation but rejected it because there was a (very low) chance that somebody may implement own task, register custom task factory and don't call _unregister_task(). I never see a code that implements asyncio task from scratch, people always reuse existing asyncio.Task. So, maybe the idea is not such bad. It can be implemented easily. I'm volunteered to make a PR with the proposal demonstration in a day or two, depending on my free time. | |
| Date | User | Action | Args | | 2019-06-12 17:26:52 | asvetlov | set | recipients: + asvetlov, thatch, lukasz.langa, yselivanov, miss-islington, sdunster, Nick Davies | | 2019-06-12 17:26:52 | asvetlov | set | messageid: <1560360412.57.0.19277940869.issue36607@roundup.psfhosted.org> | | 2019-06-12 17:26:52 | asvetlov | link | issue36607 messages | | 2019-06-12 17:26:52 | asvetlov | create | | |