Exemplo n.º 1
0
 def __init__(self, name, dont_backlog=False, **kwargs):
     self.dont_backlog = (dont_backlog or kwargs.get('is_interface', False))
     self._backlog_recv = []
     self._backlog_send = []
     self._backlog_thread = None
     self.backlog_send_ready = multitasking.Event()
     self.backlog_recv_ready = multitasking.Event()
     self.backlog_open = False
     self._used_direct = False
     super(AsyncComm, self).__init__(name, **kwargs)
Exemplo n.º 2
0
 def __init__(self, wrapped, daemon=False,
              async_recv_method='recv', async_send_method='send_message',
              async_recv_kwargs=None, async_send_kwargs=None):
     self._backlog_buffer = []
     self._backlog_thread = None
     self.backlog_ready = multitasking.Event()
     self._used_direct = False
     self.close_on_eof_recv = wrapped.close_on_eof_recv
     self._used = False
     self._closed = False
     self._backlog_received_eof = False
     self._error_registry = {}
     self.daemon = daemon
     self.async_recv_method = async_recv_method
     self.async_send_method = async_send_method
     if async_recv_kwargs is None:
         async_recv_kwargs = {}
     if async_send_kwargs is None:
         async_send_kwargs = {}
     self.async_recv_kwargs = async_recv_kwargs
     self.async_send_kwargs = async_send_kwargs
     wrapped.close_on_eof_recv = False
     wrapped.is_async = True
     super(AsyncComm, self).__init__(wrapped)
     # Open backlog to match
     if self._wrapped.is_open:
         self.open()
     if self._wrapped.is_interface:  # pragma: debug
         # atexit.register(self.atexit)
         raise RuntimeError("Use of async comm inside model is untested")
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def _init_before_open(self, **kwargs):
     r"""Initialize null variables and RMQ async thread."""
     self.times_connected = 0
     self.rmq_thread_count = 0
     self.rmq_thread = self.new_run_thread()
     self._opening = False
     self._closing = False
     self._reconnecting = False
     self._close_called = False
     self._buffered_messages = []
     self._qres = None
     self._qres_lock = multitasking.RLock()
     self._qres_event = multitasking.Event()
     self._qres_event.set()
     super(RMQAsyncComm, self)._init_before_open(**kwargs)
Exemplo n.º 5
0
 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)