mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-06 08:33:56 +00:00
Wait for client to shutdown/disconnect before stopping reactor (fixes #2032)
This commit is contained in:
parent
754a5a7f8a
commit
08a75bd9f9
@ -44,7 +44,7 @@ from deluge.ui.client import client
|
|||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.ui.gtkui.ipcinterface import process_args
|
from deluge.ui.gtkui.ipcinterface import process_args
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor, defer
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import common
|
import common
|
||||||
@ -157,12 +157,28 @@ class MainWindow(component.Component):
|
|||||||
:param shutdown: whether or not to shutdown the daemon as well
|
:param shutdown: whether or not to shutdown the daemon as well
|
||||||
:type shutdown: boolean
|
:type shutdown: boolean
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def shutdown_daemon(result):
|
||||||
|
return client.daemon.shutdown()
|
||||||
|
|
||||||
|
def disconnect_client(result):
|
||||||
|
return client.disconnect()
|
||||||
|
|
||||||
|
def stop_reactor(result):
|
||||||
|
return reactor.stop()
|
||||||
|
|
||||||
|
def log_failure(failure, action):
|
||||||
|
log.error("Encountered error attempting to %s: %s" % \
|
||||||
|
(action, failure.getErrorMessage()))
|
||||||
|
|
||||||
|
d = defer.succeed(None)
|
||||||
if shutdown:
|
if shutdown:
|
||||||
try:
|
d.addCallback(shutdown_daemon)
|
||||||
client.daemon.shutdown()
|
d.addErrback(log_failure, "shutdown daemon")
|
||||||
except AttributeError, e:
|
if not client.is_classicmode() and client.connected():
|
||||||
log.error("Encountered error attempting to shutdown daemon: %s", e)
|
d.addCallback(disconnect_client)
|
||||||
reactor.stop()
|
d.addErrback(log_failure, "disconnect client")
|
||||||
|
d.addBoth(stop_reactor)
|
||||||
|
|
||||||
def load_window_state(self):
|
def load_window_state(self):
|
||||||
x = self.config["window_x_pos"]
|
x = self.config["window_x_pos"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user