summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2012-03-02 09:15:35 -0800
committerAndrew Resch <andrewresch@gmail.com>2012-03-02 09:15:35 -0800
commit0676aaf9187f68aa74cfb256aad3e6ea3280f12b (patch)
tree54631a66db021d8bda7477722e6c93c4976ffff5
parent5d0dace1317acd9d6dcf0807a8f0507434aacf2c (diff)
downloaddeluge-0676aaf91.zip
deluge-0676aaf91.tar.gz
deluge-0676aaf91.tar.bz2
Properly wait for the component.shutdown deferred on shutdown. This should prevent the daemon from exiting before all the state has been saved.
-rw-r--r--deluge/core/daemon.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py
index 500f5da..bac5b69 100644
--- a/deluge/core/daemon.py
+++ b/deluge/core/daemon.py
@@ -110,7 +110,7 @@ class Daemon(object):
# Twisted catches signals to terminate, so just have it call the shutdown
# method.
- reactor.addSystemEventTrigger("after", "shutdown", self.shutdown)
+ reactor.addSystemEventTrigger("before", "shutdown", self._shutdown)
# Catch some Windows specific signals
if deluge.common.windows_check():
@@ -182,17 +182,16 @@ class Daemon(object):
reactor.callLater(0, reactor.stop)
def _shutdown(self, *args, **kwargs):
- try:
- os.remove(deluge.configmanager.get_config_dir("deluged.pid"))
- except Exception, e:
- log.exception(e)
- log.error("Error removing deluged.pid!")
-
- component.shutdown()
- try:
- reactor.stop()
- except twisted.internet.error.ReactorNotRunning:
- log.debug("Tried to stop the reactor but it is not running..")
+ if os.path.exists(deluge.configmanager.get_config_dir("deluged.pid")):
+ try:
+ os.remove(deluge.configmanager.get_config_dir("deluged.pid"))
+ except Exception, e:
+ log.exception(e)
+ log.error("Error removing deluged.pid!")
+
+ log.info("Waiting for components to shutdown..")
+ d = component.shutdown()
+ return d
@export()
def info(self):