Exemple #1
0
 def __init__(self, bus, worker, master_proxy, execution_features, num_threads=1):
     AsynchronousExecutePlugin.__init__(self, bus, num_threads, "execute_task")
     self.worker = worker
     self.block_store = worker.block_store
     self.master_proxy = master_proxy
     self.execution_features = execution_features
     self.current_task_set = None
     self._lock = Lock()
Exemple #2
0
 def stop(self):
     """
     Shut the plugin down.  Items which have been queued for
     deferred execution will be abandoned, as will any which have
     been queued to the worker thread but not yet started.  Waits
     until any items which have been started complete.  There's no
     built-in way to tell which items are completed and which are
     abandoned, but it's not particularly difficult to do something
     from the work items.
     """
     for timer in self.timers.values():
         timer.cancel()
     AsynchronousExecutePlugin.stop(self)
Exemple #3
0
 def __init__(self,
              bus,
              worker,
              master_proxy,
              execution_features,
              num_threads=1):
     AsynchronousExecutePlugin.__init__(self, bus, num_threads,
                                        "execute_task")
     self.worker = worker
     self.block_store = worker.block_store
     self.master_proxy = master_proxy
     self.execution_features = execution_features
     self.current_task_set = None
     self._lock = Lock()
Exemple #4
0
    def __init__(self, bus):
        """
        DeferredWorkPlugin(bus)

        Create a new deferred work worker thread and attach it to the
        bus @bus.  Work items can be enqueued using either
        do_deferred() (which runs them immediately) or
        do_deferred_after() (which runs them after a timeout).  The
        work items should be simple callables with no arguments.

        Note that there is only one worker thread, so slow items will
        prevent any other items from running.
        """
        AsynchronousExecutePlugin.__init__(self, bus, 1)
        self.timers = {}
        self.current_timer_id = 0
Exemple #5
0
 def stop(self):
     for timer in self.timers.values():
         timer.cancel()
     AsynchronousExecutePlugin.stop(self)
Exemple #6
0
 def __init__(self, bus, event_name="deferred_work"):
     AsynchronousExecutePlugin.__init__(self, bus, 1, event_name)
     self.timers = {}
     self.current_timer_id = 0