bytes_received signal: send spider argument

This commit is contained in:
Eugenio Lacuesta 2020-01-27 12:21:18 -03:00
parent 89483ce9f7
commit dbe20a863f
No known key found for this signature in database
GPG Key ID: DA3EF2D0913E9810
3 changed files with 6 additions and 2 deletions

View File

@ -162,7 +162,7 @@ bytes_received
--------------
.. signal:: bytes_received
.. function:: bytes_received(data, request)
.. function:: bytes_received(data, request, spider)
Sent by the HTTP 1.1 download handler when a group of bytes is
received for a specific request.
@ -175,6 +175,9 @@ bytes_received
:param request: the request that generated the response
:type request: :class:`~scrapy.http.Request` object
:param spider: the spider associated with the response
:type spider: :class:`~scrapy.spiders.Spider` object
spider_closed
-------------

View File

@ -482,6 +482,7 @@ class _ResponseReader(protocol.Protocol):
signal=signals.bytes_received,
data=bodyBytes,
request=self._request,
spider=self._crawler.spider,
)
if self._maxsize and self._bytes_received > self._maxsize:

View File

@ -159,7 +159,7 @@ class CrawlerRun(object):
def item_scraped(self, item, spider, response):
self.itemresp.append((item, response))
def bytes_received(self, data, request):
def bytes_received(self, data, request, spider):
self.bytes[request] += data
def request_scheduled(self, request, spider):