Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking if defer gets an error callback while in start_request and killing process #2171

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

debosmit
Copy link

This is to account for the case that an exception is being raised in the start_requests method. In scrapy/crawler.py:Crawler/crawl the values yielded are left unused. scrapy/commands/crawl.py:Command.run does nothing with the deferred that is yielded. This fix checks if an error is raised and calls sys.exit(1) if it is. The stack-trace leading to the error is also logged.

This has been tracked in issue 1231 and 1241.

@codecov-io
Copy link

codecov-io commented Aug 10, 2016

Current coverage is 83.48% (diff: 53.84%)

Merging #2171 into master will increase coverage by 0.02%

Powered by Codecov. Last update 414857a...b59312d

d = self.crawler_process.crawl(spname, **opts.spargs)

def _crawl_error(_exc):
global exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a way to have a mutable variable in a closure (i.e. something what nonlocal keyword does in Python 3)? If so, I think it is better to use another workaround, e.g. using a list of length 1 and changing its first item.

@kmike
Copy link
Member

kmike commented Sep 9, 2016

Rasing sys.exit(1) makes sense; I think the approach is correct. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants