mirror of https://github.com/scrapy/scrapy.git
engine: stopping reactor when there's nothing left to do
This commit is contained in:
parent
a7f5c6f878
commit
0643010f0c
|
|
@ -65,6 +65,8 @@ class ExecutionEngine(object):
|
|||
self.close_domain, domain, reason='shutdown')
|
||||
if self._mainloop_task.running:
|
||||
self._mainloop_task.stop()
|
||||
if reactor.running:
|
||||
reactor.stop()
|
||||
|
||||
def kill(self):
|
||||
"""Forces shutdown without waiting for pending transfers to finish.
|
||||
|
|
@ -299,9 +301,8 @@ class ExecutionEngine(object):
|
|||
stats.close_domain(domain, reason=reason)
|
||||
log.msg("Domain closed (%s)" % reason, domain=domain)
|
||||
spiders.close_domain(domain)
|
||||
if self.running:
|
||||
self._mainloop()
|
||||
elif not self.open_domains:
|
||||
self._mainloop()
|
||||
if not self.open_domains:
|
||||
send_catch_log(signal=signals.engine_stopped, sender=self.__class__)
|
||||
|
||||
scrapyengine = ExecutionEngine()
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class CrawlingSession(object):
|
|||
dispatcher.connect(self.request_received, signals.request_received)
|
||||
dispatcher.connect(self.response_downloaded, signals.response_downloaded)
|
||||
|
||||
scrapymanager.configure()
|
||||
scrapymanager.runonce(self.domain)
|
||||
self.port.stopListening()
|
||||
self.wasrun = True
|
||||
|
|
|
|||
Loading…
Reference in New Issue