Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement 'cancelled' and 'finished' events for TaskSpec.

  • Loading branch information...
commit 324fe0589934876358a8e73e6d18055a32d215da 1 parent a59997c
@knipknap authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/SpiffWorkflow/specs/TaskSpec.py
View
11 src/SpiffWorkflow/specs/TaskSpec.py
@@ -36,8 +36,8 @@ class TaskSpec(object):
- B{cancelled}: called when the state changes to CANCELLED, at a time
before the post-assign variables are assigned.
- B{finished}: called when the state changes to COMPLETED or CANCELLED,
- at the last possible time and after the post-assign variables are
- assigned.
+ at the last possible time after the post-assign variables are
+ assigned and mutexes are released.
"""
def __init__(self, parent, name, **kwargs):
@@ -90,12 +90,13 @@ def __init__(self, parent, name, **kwargs):
self.reached_event = Event()
self.ready_event = Event()
self.completed_event = Event()
+ self.cancelled_event = Event()
+ self.finished_event = Event()
self._parent._add_notify(self)
self.properties.update(self.defines)
assert self.id is not None
-
def _connect_notify(self, taskspec):
"""
Called by the previous task to let us know that it exists.
@@ -279,8 +280,9 @@ def _on_ready(self, my_task):
for lock in self.locks:
mutex = my_task.workflow._get_mutex(lock)
mutex.unlock()
- return result
+ self.finished_event.emit(my_task.workflow, my_task)
+ return result
def _on_ready_before_hook(self, my_task):
"""
@@ -316,6 +318,7 @@ def _on_cancel(self, my_task):
@rtype: boolean
@return: True on success, False otherwise.
"""
+ self.cancelled_event.emit(my_task.workflow, my_task)
return True
def _on_trigger(self, my_task):
Please sign in to comment.
Something went wrong with that request. Please try again.