提交 7727d87f 编写于 作者: P Paul Tremberth

Test Slot's heartbeat state before stopping it

Also add a test on state of looping task in LogStats extension

Fixes #2011 and #2362
上级 0f5eb4cf
......@@ -48,7 +48,8 @@ class Slot(object):
if self.closing and not self.inprogress:
if self.nextcall:
self.nextcall.cancel()
self.heartbeat.stop()
if self.heartbeat.running:
self.heartbeat.stop()
self.closing.callback(None)
......
......@@ -15,6 +15,7 @@ class LogStats(object):
self.stats = stats
self.interval = interval
self.multiplier = 60.0 / self.interval
self.task = None
@classmethod
def from_crawler(cls, crawler):
......@@ -47,5 +48,5 @@ class LogStats(object):
logger.info(msg, log_args, extra={'spider': spider})
def spider_closed(self, spider, reason):
if self.task.running:
if self.task and self.task.running:
self.task.stop()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册