Skip to content

"RuntimeError: no running event loop" from asyncio.create_task #121

Open
@SJChannel

Description

@SJChannel

I am testing with python 3.12.3 and PySide6 6.7.0. When using qasync >= 0.24.2, the attached script fails on the call to asyncio.create_task with this exception:

Traceback (most recent call last):
  File "/Users/jdp/python/./qtest.py", line 38, in <module>
    aw = MyAppWindow()
         ^^^^^^^^^^^^^
  File "/Users/jdp/python/./qtest.py", line 22, in __init__
    self.task = asyncio.create_task(self.my_task())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/tasks.py", line 417, in create_task
    loop = events.get_running_loop()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
sys:1: RuntimeWarning: coroutine 'MyAppWindow.my_task' was never awaited

The failure does not occur with qasync 0.24.0. Uncommenting the statement

#asyncio.events._set_running_loop(loop)

works around the problem, but it is undesirable because it uses a private API.
qtest.py.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions