Andrew Svetlov <andrew.svet...@gmail.com> added the comment:
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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36607> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com