Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
57a438b2 by lovetox at 2020-11-07T14:00:00+01:00
Task: Don’t allow to cancel a finished task
- - - - -
1 changed file:
- nbxmpp/task.py
Changes:
=====================================
nbxmpp/task.py
=====================================
@@ -137,7 +137,7 @@ class Task:
return self._state
def add_done_callback(self, callback, weak=True):
- if self._state in (TaskState.FINISHED, TaskState.CANCELLED):
+ if self._state.is_finished or self._state.is_cancelled:
raise RuntimeError('Task is finished')
if weak:
@@ -169,7 +169,7 @@ class Task:
def _sub_task_completed(self, task):
self._sub_task = None
- if self._state.is_cancelled:
+ if not self._state.is_running:
return
result = task.get_result()
@@ -263,7 +263,7 @@ class Task:
self._finalize_context = context
def cancel(self):
- if self._state.is_cancelled:
+ if not self._state.is_running:
return
self._state = TaskState.CANCELLED
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/57a438b2209863d50978afbefd326ae20ec0dd71
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/57a438b2209863d50978afbefd326ae20ec0dd71
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits