Flushing scheduler before shutdown
[nepi.git] / src / nepi / execution / scheduler.py
index 8d70fbb..cbd9874 100644 (file)
@@ -25,7 +25,6 @@ class TaskStatus:
     DONE = 1
     ERROR = 2
 
-
 class Task(object):
     """ This class is to define a task, that is represented by an id,
     an execution time 'timestamp' and an action 'callback """
@@ -54,6 +53,11 @@ class HeapScheduler(object):
         self._valid = set()
         self._idgen = itertools.count(1)
 
+    @property
+    def pending(self):
+        """ Returns the list of pending task ids """
+        return self._valid
+
     def schedule(self, task):
         """ Add the task 'task' in the heap of the scheduler
 
@@ -62,6 +66,7 @@ class HeapScheduler(object):
         """
         if task.id == None:
             task.id = self._idgen.next()
+
         entry = (task.timestamp, task.id, task)
         self._valid.add(task.id)
         heapq.heappush(self._queue, entry)