Skip to content

Commit 2947d41

Browse files
committed
Sprinkled some comments
1 parent 4dcab14 commit 2947d41

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scrapy_webdriver/middlewares.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def from_crawler(cls, crawler):
1717
return cls(crawler)
1818

1919
def process_start_requests(self, start_requests, spider):
20-
"""Return start requests with some reordered by the manager.
20+
"""Return start requests, with some reordered by the manager.
2121
2222
The reordering occurs as a result of some requests waiting to gain
2323
access to the webdriver instance. Those waiting requests are queued up
@@ -28,14 +28,18 @@ def process_start_requests(self, start_requests, spider):
2828
return self._process_requests(start_requests, start=True)
2929

3030
def process_spider_output(self, response, result, spider):
31-
"""Return spider result with some requests reordered by the manager.
31+
"""Return spider result, with some requests reordered by the manager.
3232
3333
See ``process_start_requests`` for a description of the reordering.
3434
3535
"""
3636
for item_or_request in self._process_requests(result):
3737
yield item_or_request
3838
if isinstance(response.request, WebdriverRequest):
39+
# We are here because the current request holds the webdriver lock.
40+
# That lock was kept for the entire duration of the response
41+
# parsing callback to keep the webdriver instance intact, and we
42+
# now release it.
3943
self.manager.release(response.request.url)
4044
next_request = self.manager.acquire_next()
4145
if next_request is not WebdriverRequest.WAITING:

0 commit comments

Comments
 (0)