Skip to content

Commit

Permalink
very fancy way to preserve back compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
whalebot-helmsman committed Apr 26, 2018
1 parent 75d5aae commit ea613bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions scrapy/spiders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from scrapy.utils.deprecate import method_is_overridden


def __flatten(list_):
return (item for sublist in list_ for item in sublist)

class Spider(object_ref):
"""Base class for scrapy spiders. All spiders must inherit from this
class.
Expand Down Expand Up @@ -83,11 +86,8 @@ def start_requests(self):
yield Request(url, dont_filter=True)

def start_requests_with_control(self):
for r in self.start_requests():
yield r

if r != signals.WaitUntilQueueEmpty:
yield signals.WaitUntilQueueEmpty
gen_ = ((r, signals.WaitUntilQueueEmpty) if r != signals.WaitUntilQueueEmpty else (r,) for r in self.start_requests())
return __flatten(gen_)

def make_requests_from_url(self, url):
""" This method is deprecated. """
Expand Down
2 changes: 1 addition & 1 deletion tests/test_crawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class TestError(Exception):
pass

class FaultySpider(SimpleSpider):
def start_requests_with_control(self):
def start_requests(self):
raise TestError

crawler = self.runner.create_crawler(FaultySpider)
Expand Down

0 comments on commit ea613bb

Please sign in to comment.