diff options
-rw-r--r-- | examples/async/eratosthenes/eratosthenes_asyncio.py | 3 | ||||
-rw-r--r-- | examples/async/minimal/minimal_asyncio.py | 3 | ||||
-rw-r--r-- | sources/pyside6/PySide6/QtAsyncio/events.py | 3 | ||||
-rw-r--r-- | sources/pyside6/PySide6/QtAsyncio/futures.py | 4 | ||||
-rw-r--r-- | sources/pyside6/PySide6/QtAsyncio/tasks.py | 2 |
5 files changed, 6 insertions, 9 deletions
diff --git a/examples/async/eratosthenes/eratosthenes_asyncio.py b/examples/async/eratosthenes/eratosthenes_asyncio.py index 0cb419817..f24a06145 100644 --- a/examples/async/eratosthenes/eratosthenes_asyncio.py +++ b/examples/async/eratosthenes/eratosthenes_asyncio.py @@ -8,7 +8,6 @@ from PySide6.QtWidgets import (QApplication, QGridLayout, QLabel, QMainWindow, Q from PySide6.QtAsyncio import QAsyncioEventLoopPolicy import asyncio -import signal import sys from random import randint @@ -132,8 +131,6 @@ if __name__ == "__main__": main_window.show() - signal.signal(signal.SIGINT, signal.SIG_DFL) - asyncio.set_event_loop_policy(QAsyncioEventLoopPolicy()) asyncio.ensure_future(eratosthenes.start()) asyncio.get_event_loop().run_forever() diff --git a/examples/async/minimal/minimal_asyncio.py b/examples/async/minimal/minimal_asyncio.py index a66e07ef6..4e6f712c3 100644 --- a/examples/async/minimal/minimal_asyncio.py +++ b/examples/async/minimal/minimal_asyncio.py @@ -7,7 +7,6 @@ from PySide6.QtWidgets import (QApplication, QLabel, QMainWindow, QPushButton, Q from PySide6.QtAsyncio import QAsyncioEventLoopPolicy import asyncio -import signal import sys @@ -60,7 +59,5 @@ if __name__ == "__main__": main_window.show() - signal.signal(signal.SIGINT, signal.SIG_DFL) - asyncio.set_event_loop_policy(QAsyncioEventLoopPolicy()) asyncio.get_event_loop().run_forever() diff --git a/sources/pyside6/PySide6/QtAsyncio/events.py b/sources/pyside6/PySide6/QtAsyncio/events.py index d9bbfc955..c570676cb 100644 --- a/sources/pyside6/PySide6/QtAsyncio/events.py +++ b/sources/pyside6/PySide6/QtAsyncio/events.py @@ -12,6 +12,7 @@ import concurrent.futures import contextvars import enum import os +import signal import socket import subprocess import typing @@ -64,6 +65,8 @@ class QAsyncioEventLoopPolicy(asyncio.AbstractEventLoopPolicy): self._application: QCoreApplication = application # type: ignore[assignment] self._event_loop: typing.Optional[asyncio.AbstractEventLoop] = None + signal.signal(signal.SIGINT, signal.SIG_DFL) + def get_event_loop(self) -> asyncio.AbstractEventLoop: if self._event_loop is None: self._event_loop = QAsyncioEventLoop(self._application) diff --git a/sources/pyside6/PySide6/QtAsyncio/futures.py b/sources/pyside6/PySide6/QtAsyncio/futures.py index 7ed8bcb64..f4ac2c561 100644 --- a/sources/pyside6/PySide6/QtAsyncio/futures.py +++ b/sources/pyside6/PySide6/QtAsyncio/futures.py @@ -33,7 +33,7 @@ class QAsyncioFuture(): self._state = QAsyncioFuture.FutureState.PENDING self._result: typing.Any = None - self._exception: typing.Optional[Exception] = None + self._exception: typing.Optional[BaseException] = None self._callbacks: typing.List[typing.Callable] = list() @@ -103,7 +103,7 @@ class QAsyncioFuture(): self._schedule_callbacks() return True - def exception(self) -> typing.Optional[Exception]: + def exception(self) -> typing.Optional[BaseException]: if self._state == QAsyncioFuture.FutureState.CANCELLED: raise asyncio.CancelledError if self.done(): diff --git a/sources/pyside6/PySide6/QtAsyncio/tasks.py b/sources/pyside6/PySide6/QtAsyncio/tasks.py index 78f9dfb0c..c8e7da7e4 100644 --- a/sources/pyside6/PySide6/QtAsyncio/tasks.py +++ b/sources/pyside6/PySide6/QtAsyncio/tasks.py @@ -88,7 +88,7 @@ class QAsyncioTask(futures.QAsyncioFuture): self._exception = e except BaseException as e: self._state = futures.QAsyncioFuture.FutureState.DONE_WITH_EXCEPTION - self._exception = e # type: ignore[assignment] + self._exception = e else: if asyncio.futures.isfuture(result): result.add_done_callback( |