mirror of https://github.com/scrapy/scrapy.git
Test Slot's heartbeat state before stopping it
Also add a test on state of looping task in LogStats extension Fixes #2011 and #2362
This commit is contained in:
parent
0f5eb4cf88
commit
7727d87f64
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue