aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2023-12-15 23:53:42 +0100
committerAdrian Herrmann <adrian.herrmann@qt.io>2023-12-19 20:53:57 +0100
commita78ddd45b5efca163c2fdc78cc6de9c53d3392e5 (patch)
tree7f260eaa9ea882facbadb724219e0e1e5f0edae0 /examples
parentda9081d40014e63405ec0e88cba5cc58a60ed0ce (diff)
QtAsyncio: Catch keyboard interrupts
Catch keyboard interrupts by catching the SIGINT signal and handling it with the default handler. Register the handler with the QAsyncioEventLoopPolicy so that this is always done when using QtAsyncio. Pick-to: 6.6 Task-number: PYSIDE-769 Change-Id: I7b35367a50ab03eb014faabf6b6a3b21a6a3cd6c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/async/eratosthenes/eratosthenes_asyncio.py3
-rw-r--r--examples/async/minimal/minimal_asyncio.py3
2 files changed, 0 insertions, 6 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()