Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Renamed exception: DontCloseDomain to DontCloseSpider (closes #120)

Pablo Hoffmana49aef2beb4e
diff --git a/scrapy/contrib/delayedclosedomain.py b/scrapy/contrib/delayedclosedomain.py
index 6a941293c..f6ae1b268 100644
--- a/scrapy/contrib/delayedclosedomain.py
+++ b/scrapy/contrib/delayedclosedomain.py
@@ -10,7 +10,7 @@ from collections import defaultdict
from scrapy.core import signals
from scrapy.core.engine import scrapyengine
-from scrapy.core.exceptions import NotConfigured, DontCloseDomain
+from scrapy.core.exceptions import NotConfigured, DontCloseSpider
from scrapy.conf import settings
@@ -33,7 +33,7 @@ class DelayedCloseDomain(object):
lastseen = self.opened_at[spider]
if time() < lastseen + self.delay:
- raise DontCloseDomain
+ raise DontCloseSpider
def spider_closed(self, spider):
self.opened_at.pop(spider, None)
diff --git a/scrapy/core/engine.py b/scrapy/core/engine.py
index d7294ab73..81d8c59ed 100644
--- a/scrapy/core/engine.py
+++ b/scrapy/core/engine.py
@@ -16,7 +16,7 @@ from scrapy.conf import settings
from scrapy.core import signals
from scrapy.core.downloader import Downloader
from scrapy.core.scraper import Scraper
-from scrapy.core.exceptions import IgnoreRequest, DontCloseDomain
+from scrapy.core.exceptions import IgnoreRequest, DontCloseSpider
from scrapy.http import Response, Request
from scrapy.spider import spiders
from scrapy.utils.misc import load_object
@@ -251,7 +251,7 @@ class ExecutionEngine(object):
def _spider_idle(self, spider):
"""Called when a spider gets idle. This function is called when there
are no remaining pages to download or schedule. It can be called
- multiple times. If some extension raises a DontCloseDomain exception
+ multiple times. If some extension raises a DontCloseSpider exception
(in the spider_idle signal handler) the spider is not closed until the
next loop and this function is guaranteed to be called (at least) once
again for this spider.
@@ -259,11 +259,12 @@ class ExecutionEngine(object):
try:
dispatcher.send(signal=signals.spider_idle, sender=self.__class__, \
spider=spider)
- except DontCloseDomain:
+ except DontCloseSpider:
reactor.callLater(5, self.next_request, spider)
return
- except:
- log.err("Exception catched on spider_idle signal dispatch")
+ except Exception, e:
+ log.msg("Exception caught on 'spider_idle' signal dispatch: %r" % e, \
+ level=log.ERROR)
if self.spider_is_idle(spider):
self.close_spider(spider, reason='finished')
diff --git a/scrapy/core/exceptions.py b/scrapy/core/exceptions.py
index 97e39de14..48204f148 100644
--- a/scrapy/core/exceptions.py
+++ b/scrapy/core/exceptions.py
@@ -25,8 +25,8 @@ class IgnoreRequest(Exception):
def __str__(self):
return self.msg
-class DontCloseDomain(Exception):
- """Request the domain not to be closed yet"""
+class DontCloseSpider(Exception):
+ """Request the spider not to be closed yet"""
pass
# Items