Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Asyncio.Event.wait doesn't resume execution when the event is set if no other tasks are active. #122938

Open
Labels
@agustinhuman

Description

@agustinhuman

Bug report

Bug description:

This is a toy program that sets an asyncio.Event when a signal is received, and runs an asynchronous function (passive_wait) that waits for that signal to be set.

When the following code is executed and a signal is sent externally, it is detected by the program, but the function waiting function does not resume execution.

It does finish correctly if another async function is executed alongside, like when uncommenting the lineactive_wait(),.

importasyncioimportsignalevent=asyncio.Event()def_signal_handler(*_)->None:event.set()print("Event triggered")signal.signal(signal.SIGINT,_signal_handler)signal.signal(signal.SIGTERM,_signal_handler)asyncdefpassive_wait():print("Pre event")awaitevent.wait()print("Post event")asyncdefactive_wait():whilenotevent.is_set():awaitasyncio.sleep(1)asyncdefmain():awaitasyncio.gather(passive_wait(),# Uncommenting the following line makes it stop correctly#active_wait(),    )asyncio.run(main())# Send the signal externally

If that's the intended behavior I would love some pointers.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp