Author twisteroid ambassador
Recipients asvetlov, twisteroid ambassador, yselivanov
Date 2019-12-21.16:04:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576944276.46.0.229840779815.issue39116@roundup.psfhosted.org>
In-reply-to
Content
I have been getting these strange exception since Python 3.8 on my Windows 10 machine. The external symptoms are many errors like "RuntimeError: aclose(): asynchronous generator is already running" and "Task was destroyed but it is pending!".

By adding try..except..logging around my code, I found that my StreamReaders would raise GeneratorExit on readexactly(). Digging deeper, it seems like the following line in StreamReader._wait_for_data():

await self._waiter

would raise a GeneratorExit.

There are only two other methods on StreamReader that actually does anything to _waiter, set_exception() and _wakeup_waiter(), but neither of these methods were called before GeneratorExit is raised. In fact, both these methods sets self._waiter to None, so normally after _wait_for_data() does "await self._waiter", self._waiter is None. However, after GeneratorExit is raised, I can see that self._waiter is not None. So it seems the GeneratorExit came from nowhere.

I have not been able to reproduce this behavior in other code. This is with Python 3.8.1 on latest Windows 10 1909, using ProactorEventLoop. I don't remember seeing this ever on Python 3.7.
History
Date User Action Args
2019-12-21 16:04:36twisteroid ambassadorsetrecipients: + twisteroid ambassador, asvetlov, yselivanov
2019-12-21 16:04:36twisteroid ambassadorsetmessageid: <1576944276.46.0.229840779815.issue39116@roundup.psfhosted.org>
2019-12-21 16:04:36twisteroid ambassadorlinkissue39116 messages
2019-12-21 16:04:36twisteroid ambassadorcreate