mirror of https://github.com/scrapy/scrapy.git
Make RetryMiddleware obey Request.meta 'dont_retry' key when processing exceptions. Closes #259
This commit is contained in:
parent
b4fbc6c5fa
commit
f5b188b179
|
|
@ -51,7 +51,8 @@ class RetryMiddleware(object):
|
|||
return response
|
||||
|
||||
def process_exception(self, request, exception, spider):
|
||||
if isinstance(exception, self.EXCEPTIONS_TO_RETRY):
|
||||
if isinstance(exception, self.EXCEPTIONS_TO_RETRY) \
|
||||
and 'dont_retry' not in request.meta:
|
||||
return self._retry(request, exception, spider)
|
||||
|
||||
def _retry(self, request, reason, spider):
|
||||
|
|
|
|||
|
|
@ -35,6 +35,13 @@ class RetryTest(unittest.TestCase):
|
|||
r = self.mw.process_response(req, rsp, self.spider)
|
||||
assert r is rsp
|
||||
|
||||
def test_dont_retry_exc(self):
|
||||
req = Request('http://www.scrapytest.org/503', meta={'dont_retry': True})
|
||||
rsp = Response('http://www.scrapytest.org/503', body='', status=503)
|
||||
|
||||
r = self.mw.process_exception(req, DNSLookupError(), self.spider)
|
||||
assert r is None
|
||||
|
||||
def test_503(self):
|
||||
req = Request('http://www.scrapytest.org/503')
|
||||
rsp = Response('http://www.scrapytest.org/503', body='', status=503)
|
||||
|
|
|
|||
Loading…
Reference in New Issue