Skip to content

AbstractEventLoop.stop() doesn't stop if nothing has been executed #124780

@electroglyph

Description

@electroglyph

Bug report

Bug description:

import asyncio
from threading import Thread
import time
loop = asyncio.new_event_loop()
def example():
    print('starting loop...')
    loop.run_forever()
async def test():
    Thread(None, example).start()
asyncio.run(test())
time.sleep(1)
loop.stop()
print('hang...')

This hangs forever. I would expect it to stop. If I add any task to the loop first, then it stops. I have an async threadpool for no-GIL, and to stop it I need to add dummy task to each loop on stop. It seems like a bug, is it a bug?

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions