本文整理汇总了Python中logbook.base.LogRecord.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python LogRecord.from_dict方法的具体用法?Python LogRecord.from_dict怎么用?Python LogRecord.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logbook.base.LogRecord
的用法示例。
在下文中一共展示了LogRecord.from_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recv
# 需要导入模块: from logbook.base import LogRecord [as 别名]
# 或者: from logbook.base.LogRecord import from_dict [as 别名]
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)
示例2: recv
# 需要导入模块: from logbook.base import LogRecord [as 别名]
# 或者: from logbook.base.LogRecord import from_dict [as 别名]
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))
示例3: recv
# 需要导入模块: from logbook.base import LogRecord [as 别名]
# 或者: from logbook.base.LogRecord import from_dict [as 别名]
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)