Skip to content

Exception and hang in Python 3.14 when using QApplication.aboutToQuit per examples #176

@benblank

Description

@benblank

In Python 3.14, using QApplication.aboutToQuit as described in the examples is resulting in an unhandled exception, after which Python hangs and the process must be killed. (I assume the "hang" is actually the event loop continuing to run without any way to interact with it?)

I can reproduce this by running examples/aiohttp_fetch.py (or even the example in the README). From a fresh checkout of qasync:

~/Documents/working/qasync $ uv sync --python 3.14 --locked
Using CPython 3.14.3 interpreter at: /usr/bin/python3.14
Creating virtual environment at: .venv
Resolved 19 packages in 0.40ms
Installed 7 packages in 12ms
 + coverage==7.10.1
 + iniconfig==2.1.0
 + packaging==25.0
 + pluggy==1.6.0
 + pygments==2.19.2
 + pytest==8.4.1
 + qasync==0.28.0 (from file:///home/five35/Documents/working/qasync)

~/Documents/working/qasync $ uv pip install --python 3.14 aiohttp PySide6
Resolved 13 packages in 8ms
Installed 13 packages in 28ms
 + aiohappyeyeballs==2.6.1
 + aiohttp==3.13.3
 + aiosignal==1.4.0
 + attrs==25.4.0
 + frozenlist==1.8.0
 + idna==3.11
 + multidict==6.7.1
 + propcache==0.4.1
 + pyside6==6.10.2
 + pyside6-addons==6.10.2
 + pyside6-essentials==6.10.2
 + shiboken6==6.10.2
 + yarl==1.23.0

~/Documents/working/qasync $ uv run --python 3.14 python examples/aiohttp_fetch.py
Exception in callback Task.task_wakeup()
handle: <Handle Task.task_wakeup()>
Traceback (most recent call last):
  File "/usr/lib/python3.14/asyncio/events.py", line 94, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: loop <QSelectorEventLoop running=False closed=False debug=False> is not the running loop

The problem doesn't occur for the examples which don't use .aboutToQuit (examples/executor_example.py and examples/modal_example.py), nor for Python 3.13.

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