add logging to shutdown process

This commit is contained in:
Job Evers-Meltzer 2016-11-03 14:42:45 -05:00
parent 10cb20d08f
commit 5bccfdb244
9 changed files with 32 additions and 9 deletions

View file

@ -25,11 +25,12 @@ class BlobAvailabilityTracker(object):
self._check_mine = LoopingCall(self._update_mine)
def start(self):
log.info("Starting blob tracker")
log.info("Starting %s", self)
self._check_popular.start(30)
self._check_mine.start(120)
def stop(self):
log.info("Stopping %s", self)
if self._check_popular.running:
self._check_popular.stop()
if self._check_mine.running:

View file

@ -1,8 +1,13 @@
import logging
from zope.interface import implements
from lbrynet.interfaces import IRateLimiter
from twisted.internet import task
log = logging.getLogger(__name__)
class DummyRateLimiter(object):
def __init__(self):
self.dl_bytes_this_second = 0
@ -64,6 +69,7 @@ class RateLimiter(object):
self.protocols = []
def start(self):
log.info("Starting %s", self)
self.tick_call = task.LoopingCall(self.tick)
self.tick_call.start(self.tick_interval)
@ -74,6 +80,7 @@ class RateLimiter(object):
self.unthrottle_ul()
def stop(self):
log.info("Stopping %s", self)
if self.tick_call is not None:
self.tick_call.stop()
self.tick_call = None

View file

@ -169,6 +169,7 @@ class Session(object):
def shut_down(self):
"""Stop all services"""
log.info('Shutting down %s', self)
ds = []
if self.blob_manager is not None:
ds.append(defer.maybeDeferred(self.blob_tracker.stop))
@ -323,7 +324,7 @@ class Session(object):
return dl
def _unset_upnp(self):
log.info("Unsetting upnp for %s", self)
def threaded_unset_upnp():
u = miniupnpc.UPnP()
num_devices_found = u.discover()

View file

@ -97,9 +97,8 @@ class Wallet(object):
log.error("An error occurred stopping the wallet: %s", err.getTraceback())
def stop(self):
log.info("Stopping %s", self)
self.stopped = True
# If self.next_manage_call is None, then manage is currently running or else
# start has not been called, so set stopped and do nothing else.
if self.next_manage_call is not None:

View file

@ -1,8 +1,13 @@
import binascii
import logging
from zope.interface import implements
from lbrynet.interfaces import IPeerFinder
log = logging.getLogger(__name__)
class DHTPeerFinder(object):
"""This class finds peers which have announced to the DHT that they have certain blobs"""
implements(IPeerFinder)
@ -21,6 +26,7 @@ class DHTPeerFinder(object):
self.next_manage_call = reactor.callLater(60, self.run_manage_loop)
def stop(self):
log.info("Stopping %s", self)
if self.next_manage_call is not None and self.next_manage_call.active():
self.next_manage_call.cancel()
self.next_manage_call = None

View file

@ -1,6 +1,11 @@
import binascii
from twisted.internet import defer, reactor
import collections
import logging
from twisted.internet import defer, reactor
log = logging.getLogger(__name__)
class DHTHashAnnouncer(object):
@ -22,6 +27,7 @@ class DHTHashAnnouncer(object):
self.next_manage_call = reactor.callLater(60, self.run_manage_loop)
def stop(self):
log.info("Stopping %s", self)
if self.next_manage_call is not None:
self.next_manage_call.cancel()
self.next_manage_call = None

View file

@ -160,7 +160,7 @@ class EncryptedFileManager(object):
return defer.fail(Failure(ValueError("Could not find that LBRY file")))
def stop(self):
log.info('Stopping %s', self)
ds = []
def wait_for_finished(lbry_file, count=2):

View file

@ -560,6 +560,7 @@ class Daemon(AuthJSONRPCServer):
try:
if self.lbry_server_port is not None:
self.lbry_server_port, p = None, self.lbry_server_port
log.info('Stop listening to %s', p)
return defer.maybeDeferred(p.stopListening)
else:
return defer.succeed(True)
@ -649,13 +650,14 @@ class Daemon(AuthJSONRPCServer):
log.warn('Failed to upload log', exc_info=True)
d = defer.succeed(None)
d.addCallback(lambda _: self._stop_server())
d.addErrback(log_support.failure, log, 'Failure while shutting down: %s')
d.addCallback(lambda _: self._stop_reflector())
d.addErrback(lambda err: True)
d.addErrback(log_support.failure, log, 'Failure while shutting down: %s')
d.addCallback(lambda _: self.lbry_file_manager.stop())
d.addErrback(lambda err: True)
d.addErrback(log_support.failure, log, 'Failure while shutting down: %s')
if self.session is not None:
d.addCallback(lambda _: self.session.shut_down())
d.addErrback(lambda err: True)
d.addErrback(log_support.failure, log, 'Failure while shutting down: %s')
return d
def _update_settings(self, settings):

View file

@ -66,6 +66,7 @@ class LBRYDaemonApp(AppKit.NSApplication):
webbrowser.open(settings.UI_ADDRESS)
def replyToApplicationShouldTerminate_(self, shouldTerminate):
log.info('Shutting down')
notify("Goodbye!")
reactor.stop()