Skip to content

Commit 0349bbf

Browse files
committed
Disable SpiderState extension if no JOBDIR set
1 parent 0d368c5 commit 0349bbf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scrapy/extensions/spiderstate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from six.moves import cPickle as pickle
33

44
from scrapy import signals
5+
from scrapy.exceptions import NotConfigured
56
from scrapy.utils.job import job_dir
67

78
class SpiderState(object):
@@ -12,7 +13,11 @@ def __init__(self, jobdir=None):
1213

1314
@classmethod
1415
def from_crawler(cls, crawler):
15-
obj = cls(job_dir(crawler.settings))
16+
jobdir = job_dir(crawler.settings)
17+
if not jobdir:
18+
raise NotConfigured
19+
20+
obj = cls(jobdir)
1621
crawler.signals.connect(obj.spider_closed, signal=signals.spider_closed)
1722
crawler.signals.connect(obj.spider_opened, signal=signals.spider_opened)
1823
return obj

0 commit comments

Comments
 (0)