Ejemplo n.º 1
0
 def recv(self, timeout=None):
     if timeout is None:
         rv = self.queue.get()
     else:
         try:
             rv = self.queue.get(block=False, timeout=timeout)
         except Empty:
             return None
     return LogRecord.from_dict(rv)
Ejemplo n.º 2
0
 def recv(self, timeout=None):
     if timeout is None:
         rv = self.queue.get()
     else:
         try:
             rv = self.queue.get(block=False, timeout=timeout)
         except Empty:
             return None
     return LogRecord.from_dict(rv)
Ejemplo n.º 3
0
 def recv(self, timeout=-1):
     try:
         rv = self.channel.receive(timeout=timeout)
     except self.channel.RemoteError:
         #XXX: handle
         return None
     except (self.channel.TimeoutError, EOFError):
         return None
     else:
         return LogRecord.from_dict(rv)
Ejemplo n.º 4
0
 def recv(self, timeout=None):
     try:
         rv = self.channel.receive(timeout=timeout)
     except self.channel.RemoteError:
         #XXX: handle
         return None
     except (self.channel.TimeoutError, EOFError):
         return None
     else:
         return LogRecord.from_dict(rv)
Ejemplo n.º 5
0
 def recv(self, timeout=None):
     """Receives a single record from the socket.  Timeout of 0 means nonblocking,
     `None` means blocking and otherwise it's a timeout in seconds after which
     the function just returns with `None`.
     """
     if timeout is None:
         rv = self.socket.recv()
     elif not timeout:
         rv = self.socket.recv(self._zmq.NOBLOCK)
         if rv is None:
             return
     else:
         if not self._zmq.select([self.socket], [], [], timeout)[0]:
             return
         rv = self.socket.recv(self._zmq.NOBLOCK)
     return LogRecord.from_dict(json.loads(rv))
Ejemplo n.º 6
0
 def recv(self, timeout=None):
     """Receives a single record from the socket.  Timeout of 0 means nonblocking,
     `None` means blocking and otherwise it's a timeout in seconds after which
     the function just returns with `None`.
     """
     if timeout is None:
         rv = self.socket.recv()
     elif not timeout:
         rv = self.socket.recv(self._zmq.NOBLOCK)
         if rv is None:
             return
     else:
         if not self._zmq.select([self.socket], [], [], timeout)[0]:
             return
         rv = self.socket.recv(self._zmq.NOBLOCK)
     return LogRecord.from_dict(json.loads(rv))
Ejemplo n.º 7
0
 def recv(self, timeout=None):
     """Overwrite standard recv for timeout calls to catch interrupt errors.
     """
     if timeout:
         try:
             testsock = self._zmq.select([self.socket], [], [], timeout)[0]
         except zmq.ZMQError as e:
             if e.errno == errno.EINTR:
                 testsock = None
             else:
                 raise
         if not testsock:
             return
         rv = self.socket.recv(self._zmq.NOBLOCK)
         return LogRecord.from_dict(json.loads(rv))
     else:
         return super(ZeroMQPullSubscriber, self).recv(timeout)
Ejemplo n.º 8
0
    def recv(self, timeout=None):
        """Receives a single record from the socket.  Timeout of 0 means nonblocking,
        `None` means blocking and otherwise it's a timeout in seconds after which
        the function just returns with `None`.
        """
        if timeout == 0:
            try:
                rv = self.queue.get(block=False)
            except Exception:
                return
        else:
            rv = self.queue.get(timeout=timeout)

        log_record = rv.payload
        rv.ack()

        return LogRecord.from_dict(log_record)
Ejemplo n.º 9
0
    def recv(self, timeout=None):
        """Receives a single record from the socket.  Timeout of 0 means nonblocking,
        `None` means blocking and otherwise it's a timeout in seconds after which
        the function just returns with `None`.
        """
        if timeout == 0:
            try:
                rv = self.queue.get(block=False)
            except Exception:
                return
        else:
            rv = self.queue.get(timeout=timeout)

        log_record = rv.payload
        rv.ack()

        return LogRecord.from_dict(log_record)
 def recv(self, timeout=None):
     """Overwrite standard recv for timeout calls to catch interrupt errors.
     """
     if timeout:
         try:
             testsock = self._zmq.select([self.socket], [], [], timeout)[0]
         except zmq.ZMQError as e:
             if e.errno == errno.EINTR:
                 testsock = None
             else:
                 raise
         if not testsock:
             return
         rv = self.socket.recv(self._zmq.NOBLOCK)
         return LogRecord.from_dict(json.loads(rv))
     else:
         return super(ZeroMQPullSubscriber, self).recv(timeout)