commit
6081b77167
7 changed files with 27 additions and 46 deletions
|
@ -18,8 +18,9 @@ at anytime.
|
|||
*
|
||||
|
||||
### Fixed
|
||||
*
|
||||
*
|
||||
* Fix multiple reactor.stop() calls
|
||||
* Properly shut down lbryum wallet from lbrynet
|
||||
* Set LBRYumWallet.config upon initialization, fixes attribute error
|
||||
|
||||
### Deprecated
|
||||
*
|
||||
|
|
|
@ -868,6 +868,7 @@ class LBRYumWallet(Wallet):
|
|||
def __init__(self, storage, config=None):
|
||||
Wallet.__init__(self, storage)
|
||||
self._config = config
|
||||
self.config = make_config(self._config)
|
||||
self.network = None
|
||||
self.wallet = None
|
||||
self.is_first_run = False
|
||||
|
@ -885,7 +886,6 @@ class LBRYumWallet(Wallet):
|
|||
|
||||
def _start(self):
|
||||
network_start_d = defer.Deferred()
|
||||
self.config = make_config(self._config)
|
||||
|
||||
def setup_network():
|
||||
self.network = Network(self.config)
|
||||
|
@ -938,8 +938,12 @@ class LBRYumWallet(Wallet):
|
|||
self.network = None
|
||||
d.callback(True)
|
||||
|
||||
if self.wallet:
|
||||
self.wallet.stop_threads()
|
||||
log.info("Stopped wallet")
|
||||
if self.network:
|
||||
self.network.stop()
|
||||
log.info("Stopped connection to lbryum server")
|
||||
|
||||
stop_check = task.LoopingCall(check_stopped)
|
||||
stop_check.start(.1)
|
||||
|
|
|
@ -178,21 +178,6 @@ class KademliaProtocol(protocol.DatagramProtocol):
|
|||
df.callback((message, address))
|
||||
elif isinstance(message, msgtypes.ErrorMessage):
|
||||
# The RPC request raised a remote exception; raise it locally
|
||||
if message.exceptionType.startswith('exceptions.'):
|
||||
exceptionClassName = message.exceptionType[11:]
|
||||
else:
|
||||
localModuleHierarchy = self.__module__.split('.')
|
||||
remoteHierarchy = message.exceptionType.split('.')
|
||||
# strip the remote hierarchy
|
||||
while remoteHierarchy[0] == localModuleHierarchy[0]:
|
||||
remoteHierarchy.pop(0)
|
||||
localModuleHierarchy.pop(0)
|
||||
exceptionClassName = '.'.join(remoteHierarchy)
|
||||
remoteException = None
|
||||
try:
|
||||
exec 'remoteException = %s("%s")' % (exceptionClassName, message.response)
|
||||
except Exception:
|
||||
# We could not recreate the exception; create a generic one
|
||||
remoteException = Exception(message.response)
|
||||
df.errback(remoteException)
|
||||
else:
|
||||
|
|
|
@ -169,8 +169,6 @@ class Daemon(AuthJSONRPCServer):
|
|||
|
||||
def __init__(self, root, analytics_manager):
|
||||
AuthJSONRPCServer.__init__(self, conf.settings['use_auth_http'])
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
|
||||
|
||||
self.allowed_during_startup = [
|
||||
'stop', 'status', 'version',
|
||||
# delete these once they are fully removed:
|
||||
|
@ -239,6 +237,8 @@ class Daemon(AuthJSONRPCServer):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def setup(self, launch_ui):
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
|
||||
|
||||
self._modify_loggly_formatter()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
@ -1281,6 +1281,7 @@ class Daemon(AuthJSONRPCServer):
|
|||
"""
|
||||
return self.jsonrpc_daemon_stop()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def jsonrpc_daemon_stop(self):
|
||||
"""
|
||||
Stop lbrynet-daemon
|
||||
|
@ -1289,13 +1290,10 @@ class Daemon(AuthJSONRPCServer):
|
|||
(string) Shutdown message
|
||||
"""
|
||||
|
||||
def _display_shutdown_message():
|
||||
log.info("Shutting down lbrynet daemon")
|
||||
|
||||
d = self._shutdown()
|
||||
d.addCallback(lambda _: _display_shutdown_message())
|
||||
d.addCallback(lambda _: reactor.callLater(0.0, reactor.stop))
|
||||
return self._render_response("Shutting down")
|
||||
response = yield self._render_response("Shutting down")
|
||||
reactor.callLater(0.1, reactor.fireSystemEvent, "shutdown")
|
||||
defer.returnValue(response)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def jsonrpc_file_list(self, **kwargs):
|
||||
|
|
|
@ -120,22 +120,15 @@ def start_server_and_listen(launchui, use_auth, analytics_manager, max_tries=5):
|
|||
analytics_manager: to send analytics
|
||||
"""
|
||||
analytics_manager.send_server_startup()
|
||||
tries = 1
|
||||
while tries < max_tries:
|
||||
log.info('Making attempt %s / %s to startup', tries, max_tries)
|
||||
try:
|
||||
daemon_server = DaemonServer(analytics_manager)
|
||||
try:
|
||||
yield daemon_server.start(use_auth, launchui)
|
||||
analytics_manager.send_server_startup_success()
|
||||
break
|
||||
except Exception as e:
|
||||
log.exception('Failed to startup')
|
||||
yield daemon_server.stop()
|
||||
analytics_manager.send_server_startup_error(str(e))
|
||||
tries += 1
|
||||
else:
|
||||
log.warn("Exceeded max tries to start up, stopping")
|
||||
reactor.callFromThread(reactor.stop)
|
||||
reactor.fireSystemEvent("shutdown")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -55,6 +55,7 @@ class DaemonServer(object):
|
|||
if self.server_port is not None:
|
||||
yield self.server_port.stopListening()
|
||||
|
||||
|
||||
def get_site_base(use_auth, root):
|
||||
if use_auth:
|
||||
log.info("Using authenticated API")
|
||||
|
|
|
@ -2,7 +2,7 @@ import time
|
|||
import requests
|
||||
import logging
|
||||
import json
|
||||
from twisted.internet import defer, threads, reactor
|
||||
from twisted.internet import defer, threads
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
from lbrynet import conf
|
||||
|
@ -167,7 +167,6 @@ def get_default_market_feed(currency_pair):
|
|||
|
||||
class ExchangeRateManager(object):
|
||||
def __init__(self):
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
|
||||
self.market_feeds = [
|
||||
get_default_market_feed(currency_pair) for currency_pair in CURRENCY_PAIRS]
|
||||
|
||||
|
|
Loading…
Reference in a new issue