From be76490002c3f478882ffd52ba8e88b8ce5ab551 Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Thu, 3 Sep 2009 10:25:55 -0300 Subject: [PATCH] avoid stopping reactor if it's already in shutdown stage (where reactor.running is still True) --- scrapy/core/engine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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.