Changeset 1859:182c9a1c0182
- Timestamp:
- 11/21/09 15:06:03 (8 months ago)
- Author:
- Pablo Hoffman <pablo@…>
- Branch:
- default
- Message:
-
Renamed exception: DontCloseDomain? to DontCloseSpider? (closes #120)
- Location:
- scrapy
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1822
|
r1859
|
|
| 11 | 11 | from scrapy.core import signals |
| 12 | 12 | from scrapy.core.engine import scrapyengine |
| 13 | | from scrapy.core.exceptions import NotConfigured, DontCloseDomain |
| | 13 | from scrapy.core.exceptions import NotConfigured, DontCloseSpider |
| 14 | 14 | from scrapy.conf import settings |
| 15 | 15 | |
| … |
… |
|
| 34 | 34 | |
| 35 | 35 | if time() < lastseen + self.delay: |
| 36 | | raise DontCloseDomain |
| | 36 | raise DontCloseSpider |
| 37 | 37 | |
| 38 | 38 | def spider_closed(self, spider): |
-
|
r1850
|
r1859
|
|
| 17 | 17 | from scrapy.core.downloader import Downloader |
| 18 | 18 | from scrapy.core.scraper import Scraper |
| 19 | | from scrapy.core.exceptions import IgnoreRequest, DontCloseDomain |
| | 19 | from scrapy.core.exceptions import IgnoreRequest, DontCloseSpider |
| 20 | 20 | from scrapy.http import Response, Request |
| 21 | 21 | from scrapy.spider import spiders |
| … |
… |
|
| 252 | 252 | """Called when a spider gets idle. This function is called when there |
| 253 | 253 | are no remaining pages to download or schedule. It can be called |
| 254 | | multiple times. If some extension raises a DontCloseDomain exception |
| | 254 | multiple times. If some extension raises a DontCloseSpider exception |
| 255 | 255 | (in the spider_idle signal handler) the spider is not closed until the |
| 256 | 256 | next loop and this function is guaranteed to be called (at least) once |
| … |
… |
|
| 260 | 260 | dispatcher.send(signal=signals.spider_idle, sender=self.__class__, \ |
| 261 | 261 | spider=spider) |
| 262 | | except DontCloseDomain: |
| | 262 | except DontCloseSpider: |
| 263 | 263 | reactor.callLater(5, self.next_request, spider) |
| 264 | 264 | return |
| 265 | | except: |
| 266 | | log.err("Exception catched on spider_idle signal dispatch") |
| | 265 | except Exception, e: |
| | 266 | log.msg("Exception caught on 'spider_idle' signal dispatch: %r" % e, \ |
| | 267 | level=log.ERROR) |
| 267 | 268 | if self.spider_is_idle(spider): |
| 268 | 269 | self.close_spider(spider, reason='finished') |
-
|
r1657
|
r1859
|
|
| 26 | 26 | return self.msg |
| 27 | 27 | |
| 28 | | class DontCloseDomain(Exception): |
| 29 | | """Request the domain not to be closed yet""" |
| | 28 | class DontCloseSpider(Exception): |
| | 29 | """Request the spider not to be closed yet""" |
| 30 | 30 | pass |
| 31 | 31 | |