Merge pull request #2918 from HarrisonGregg/fix/inspect-response-signal-handling

Fix SIGINT handling when using inspect_response
This commit is contained in:
Mikhail Korobov 2023-01-11 17:24:04 +05:00 committed by GitHub
commit 3252097b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -163,7 +163,11 @@ class Shell:
def inspect_response(response, spider):
"""Open a shell to inspect the given response"""
# Shell.start removes the SIGINT handler, so save it and re-add it after
# the shell has closed
sigint_handler = signal.getsignal(signal.SIGINT)
Shell(spider.crawler).start(response=response, spider=spider)
signal.signal(signal.SIGINT, sigint_handler)
def _request_deferred(request):