def __init__(self, connection, **kwargs): self.connection = connection self.q_tasks = multitasking.Queue( task_method='process', task_context=connection.process_instance.context) self.q_results = multitasking.Queue( task_method='process', task_context=connection.process_instance.context) super(RemoteTaskLoop, self).__init__(target=self.target, **kwargs) # Overwrite break flag with process safe Event self.break_flag = multitasking.Event( task_method='process', task_context=connection.process_instance.context)
def _init_before_open(self, **kwargs): r"""Initialize null variables and RMQ async thread.""" self.original_queue = None self.times_connected = 0 self.rmq_thread_count = 0 self.rmq_thread = self.new_run_thread() self._consuming = multitasking.ProcessEvent(task_method='thread') self._reconnecting = multitasking.ProcessEvent(task_method='thread') self._reconnect_delay = 0 self._prefetch_count = 2 self._buffered_messages = multitasking.Queue(task_method='thread') self._deliveries = multitasking.LockedDict(task_method='thread') self._external_close = multitasking.Event(task_method='thread') # self._publish_interval = 0 self._acked = 0 self._nacked = 0 self._message_number = 0 super(RMQAsyncComm, self)._init_before_open(**kwargs) self._opening.stopped.add_callback(self._reconnecting.stop)