diff options
| author | Adrian Herrmann <adrian.herrmann@qt.io> | 2023-09-18 22:46:02 +0200 |
|---|---|---|
| committer | Adrian Herrmann <adrian.herrmann@qt.io> | 2023-09-19 13:20:41 +0200 |
| commit | 010592b188351014c9015c6dfe61de7c1f0a8769 (patch) | |
| tree | c986576bc75e6a9a24790bab1257889c228b48ad /sources/pyside6/PySide6/QtAsyncio/tasks.py | |
| parent | 5a2f3e141ee5a169542afe96a9ab2298679aa1fa (diff) | |
QtAsyncio: Fix signature of cancel for future/task
QAsyncioFuture.cancel() and QAsyncioTask.cancel() should both return a
bool.
Pick-to: 6.6
Task-number: PYSIDE-769
Change-Id: I2b507ad5c44ba9478bdf8a53c0cd5464028d3384
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.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sources/pyside6/PySide6/QtAsyncio/tasks.py b/sources/pyside6/PySide6/QtAsyncio/tasks.py index bc84571b6..0ee482f38 100644 --- a/sources/pyside6/PySide6/QtAsyncio/tasks.py +++ b/sources/pyside6/PySide6/QtAsyncio/tasks.py @@ -126,11 +126,14 @@ class QAsyncioTask(futures.QAsyncioFuture): def set_name(self, value) -> None: self._name = str(value) - def cancel(self, msg: typing.Optional[str] = None) -> None: + def cancel(self, msg: typing.Optional[str] = None) -> bool: + if self.done(): + return False if (isinstance(self._handle, events.QAsyncioHandle)): self._handle._cancel_exception_msg = msg self._handle.cancel() self._state = futures.QAsyncioFuture.FutureState.CANCELLED + return True def uncancel(self) -> None: # TODO |
