Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

avoid stopping reactor if it's already in shutdown stage (where reactor.running is still True)

Pablo Hoffmanbe76490002c3
diff --git a/scrapy/core/engine.py b/scrapy/core/engine.py
index 74fe8abd7..60a0893be 100644
--- a/scrapy/core/engine.py
+++ b/scrapy/core/engine.py
@@ -65,8 +65,10 @@ class ExecutionEngine(object):
self.close_domain, domain, reason='shutdown')
if self._mainloop_task.running:
self._mainloop_task.stop()
- if reactor.running:
+ try:
reactor.stop()
+ except RuntimeError: # raised if already stopped or in shutdown stage
+ pass
def kill(self):
"""Forces shutdown without waiting for pending transfers to finish.