Skip to content

Commit 74413ff

Browse files
committed
prevent incorrect assertion error possible when spiders are closing
1 parent 16d9a33 commit 74413ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scrapy/core/engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def has_capacity(self):
130130
return len(self.downloader.sites) < self.downloader.concurrent_spiders
131131

132132
def crawl(self, request, spider):
133-
assert spider in self.open_spiders, \
134-
"Spider %r not opened when crawling: %s" % (spider.name, request)
135133
if spider in self.closing: # ignore requests for spiders being closed
136134
return
135+
assert spider in self.open_spiders, \
136+
"Spider %r not opened when crawling: %s" % (spider.name, request)
137137
schd = mustbe_deferred(self.schedule, request, spider)
138138
# FIXME: we can't log errors because we would be preventing them from
139139
# propagating to the request errback. This should be fixed after the

0 commit comments

Comments
 (0)