aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/QtAsyncio/tasks.py
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2023-09-18 22:44:52 +0200
committerAdrian Herrmann <adrian.herrmann@qt.io>2023-09-19 13:20:41 +0200
commit5a2f3e141ee5a169542afe96a9ab2298679aa1fa (patch)
tree0f5142ce6cf479dfc39638e50ef5a86728e2c91c /sources/pyside6/PySide6/QtAsyncio/tasks.py
parenteec936657938e1c19ab70c562fc5eff5e1cec4b9 (diff)
QtAsyncio: Use asyncio._enter_task and _leave_task
Wrap a QAsyncioTask's step execution with calls to asyncio._enter_task() and asyncio._leave_task() so that asyncio.current_task() will work. Pick-to: 6.6 Task-number: PYSIDE-769 Change-Id: I7235c9ab2b8d68b0059b82a366909dc25ea6d60f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6/QtAsyncio/tasks.py')
-rw-r--r--sources/pyside6/PySide6/QtAsyncio/tasks.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtAsyncio/tasks.py b/sources/pyside6/PySide6/QtAsyncio/tasks.py
index 05ee17dd6..bc84571b6 100644
--- a/sources/pyside6/PySide6/QtAsyncio/tasks.py
+++ b/sources/pyside6/PySide6/QtAsyncio/tasks.py
@@ -64,6 +64,9 @@ class QAsyncioTask(futures.QAsyncioFuture):
if self.done():
return
result = None
+
+ asyncio._enter_task(self._loop, self) # type: ignore[arg-type]
+
try:
if exception_or_future is None:
result = self._coro.send(None)
@@ -104,6 +107,8 @@ class QAsyncioTask(futures.QAsyncioFuture):
self._schedule_callbacks()
self._loop.stop()
+ asyncio._leave_task(self._loop, self) # type: ignore[arg-type]
+
def get_stack(self, *, limit=None) -> typing.List[typing.Any]:
# TODO
raise NotImplementedError("QtTask.get_stack is not implemented")