def __enter__(self):
if not isinstance(threading.current_thread(), threading._MainThread):
logging.warning("timeout only works on main thread, are you running pyspider in threads?")
self.seconds = 0
if self.seconds:
signal.signal(signal.SIGALRM, self.handle_timeout)
signal.alarm(int(math.ceil(self.seconds)))
评论列表
文章目录