Skip to content

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

callLater must happens before timeout callback is added to avoid AttributeError

Daniel Graña22da89b7488f
diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.py
index bdef52eb5..65ac8a5ae 100644
--- a/scrapy/core/downloader/handlers/http11.py
+++ b/scrapy/core/downloader/handlers/http11.py
@@ -78,8 +78,8 @@ class ScrapyAgent(object):
d.addCallback(self._cb_bodyready, request)
d.addCallback(self._cb_bodydone, request, url)
# check download timeout
- d.addBoth(self._cb_timeout, request, url, timeout)
self._timeout_cl = reactor.callLater(timeout, d.cancel)
+ d.addBoth(self._cb_timeout, request, url, timeout)
return d
def _cb_timeout(self, result, request, url, timeout):