aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2024-04-23 17:23:40 +0200
committerAdrian Herrmann <adrian.herrmann@qt.io>2024-04-24 13:32:41 +0200
commit29136f0186d5f281f751c8974ae888913e5d765a (patch)
tree7a050d1a1d2ab9434b46369369040576d6c5f4d5 /sources/pyside6
parentf34dcb84adf20e9f3428660636aa8d377d14fc3b (diff)
QtAsyncio: Improve readability of _step
Improve the readability of the QAsyncioTask._step function; avoid nested try/except blocks. Pick-to: 6.7 Task-number: PYSIDE-769 Change-Id: Ibb82c50cf93b084b30dd2a5abcc0197ae25802e0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/PySide6/QtAsyncio/tasks.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/sources/pyside6/PySide6/QtAsyncio/tasks.py b/sources/pyside6/PySide6/QtAsyncio/tasks.py
index 6777b8bc3..c04006686 100644
--- a/sources/pyside6/PySide6/QtAsyncio/tasks.py
+++ b/sources/pyside6/PySide6/QtAsyncio/tasks.py
@@ -64,19 +64,18 @@ class QAsyncioTask(futures.QAsyncioFuture):
result = None
self._future_to_await = None
+ if asyncio.futures.isfuture(exception_or_future):
+ try:
+ exception_or_future.result()
+ except BaseException as e:
+ exception_or_future = e
+
try:
asyncio._enter_task(self._loop, self) # type: ignore[arg-type]
- if exception_or_future is None:
- result = self._coro.send(None)
- elif asyncio.futures.isfuture(exception_or_future):
- try:
- exception_or_future.result()
- except BaseException as e:
- result = self._coro.throw(e)
- else:
- result = self._coro.send(None)
- elif isinstance(exception_or_future, BaseException):
+ if isinstance(exception_or_future, BaseException):
result = self._coro.throw(exception_or_future)
+ else:
+ result = self._coro.send(None)
except StopIteration as e:
self._state = futures.QAsyncioFuture.FutureState.DONE_WITH_RESULT
self._result = e.value