def __init__(self, child, timelimit, greedy=False, use_alarm=True):
"""
:param child: the collector to wrap.
:param timelimit: the maximum amount of time (in seconds) to
allow for searching. If the search takes longer than this, it will
raise a ``TimeLimit`` exception.
:param greedy: if ``True``, the collector will finish adding the most
recent hit before raising the ``TimeLimit`` exception.
:param use_alarm: if ``True`` (the default), the collector will try to
use signal.SIGALRM (on UNIX).
"""
self.child = child
self.timelimit = timelimit
self.greedy = greedy
if use_alarm:
import signal
self.use_alarm = use_alarm and hasattr(signal, "SIGALRM")
else:
self.use_alarm = False
self.timer = None
self.timedout = False
评论列表
文章目录