This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ben.Darnell
Recipients Ben.Darnell, Jonathan Slenders, asvetlov, cjrh, yselivanov
Date 2020-02-16.15:05:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I just spent some time digging into this. Each call to `run_forever` starts a call to `_loop_self_reading`, then attempts to cancel it before returning:

The comment at line 321 is not entirely accurate: the future will not resolve in the future, but it may have *already* resolved, and added its callback to the call_soon queue. This callback will run if the event loop is restarted again. Since `_loop_self_reading` calls itself, this results in two copies of the "loop" running concurrently and stepping on each other's `_self_reading_futures`. 

This appears to be fairly harmless except for noise in the logs when only one of the loops is stopped cleanly.

I believe the simplest fix is for `_loop_self_reading` to compare its argument to `self._self_reading_future` to determine if it is the "current" loop and if not, don't reschedule anything.
Date User Action Args
2020-02-16 15:05:06Ben.Darnellsetrecipients: + Ben.Darnell, asvetlov, cjrh, yselivanov, Jonathan Slenders
2020-02-16 15:05:06Ben.Darnellsetmessageid: <>
2020-02-16 15:05:06Ben.Darnelllinkissue39010 messages
2020-02-16 15:05:06Ben.Darnellcreate