classification
Title: stop() on a stopped loop inhibits the next run_forever
Type: behavior Stage: patch review
Components: asyncio Versions: Python 3.11, Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: WhosMega, asvetlov, mandolaerik, yselivanov
Priority: normal Keywords: patch

Created on 2021-05-24 13:55 by mandolaerik, last changed 2021-06-02 10:26 by WhosMega.

Pull Requests
URL Status Linked Edit
PR 26483 closed WhosMega, 2021-06-02 10:26
Messages (2)
msg394250 - (view) Author: Erik Carstensen (mandolaerik) Date: 2021-05-24 13:54
If you call stop() on an already stopped event loop, then the next call to run_forever will terminate after one loop iteration. I would expect the stop to either be a nop, or to be invalid in this state (and raise an exception).

Example:

import asyncio
async def coro(x):
    print(x)
    if x < 10:
        asyncio.create_task(coro(x+1))
loop = asyncio.get_event_loop()
loop.create_task(coro(0))
loop.stop()
loop.run_forever()
msg394896 - (view) Author: megahypex (WhosMega) Date: 2021-06-02 07:57
Can I be assigned this issue?
History
Date User Action Args
2021-06-02 10:26:05WhosMegasetkeywords: + patch
stage: patch review
pull_requests: + pull_request25079
2021-06-02 07:57:37WhosMegasetnosy: + WhosMega
messages: + msg394896
2021-05-28 19:26:39terry.reedysetversions: - Python 3.7, Python 3.8, Python 3.9
2021-05-24 13:55:00mandolaerikcreate