Exemplo n.º 1
0
 def __del__(self):
     # It's really important to close sockets before the context is
     # attempted terminated (which it is when it's garbage
     # collected). Any open sockets will block the termination,
     # effectively causing the entire Python-process to hang.
     for socket_name, socket in self._socket_by_name.items():
         try:
             socket.close()
         except:
             # Nothing we can do, but we'll want to try to close the other sockets.
             log.error('Could not close ZeroMQ-socket named "%s"' % socket_name)
             util.reraise_if_should_exit()
Exemplo n.º 2
0
 def handle_messages(self, message_batch):
     try:
         for message in message_batch:
             try:
                 pipeline = yield self.pipeline_dependency.wait_for_resource()
                 # TODO: We ought to have a cooperator somewhere
                 # else, for all the pipelines regardless of where
                 # the batons come from.
                 cooperative = task.cooperate(iter([pipeline.process(message).addErrback(self._log_process_error)]))
                 yield cooperative.whenDone()
             except:
                 util.reraise_if_should_exit()
                 log.error()
     finally:
         self._register_in_poller()