From 80b2bc1c9a4ae650b7d5ecf099338ac8d2df633c Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Mon, 4 Nov 2019 20:17:36 +0530 Subject: [PATCH] class_singleCleaner.py quality fixes --- src/class_singleCleaner.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index 9ffc1607..68a5e727 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -21,11 +21,11 @@ It resends messages when there has been no response: import gc import os -import shared import time import knownnodes import queues +import shared import state import tr from bmconfigparser import BMConfigParser @@ -35,11 +35,12 @@ from network import BMConnectionPool, StoppableThread class singleCleaner(StoppableThread): + """The singleCleaner thread class""" name = "singleCleaner" cycleLength = 300 expireDiscoveredPeers = 300 - def run(self): + def run(self): # pylint: disable=too-many-branches gc.disable() timeWeLastClearedInventoryAndPubkeysTables = 0 try: @@ -115,6 +116,7 @@ class singleCleaner(StoppableThread): # while writing it to disk knownnodes.cleanupKnownNodes() except Exception as err: + # pylint: disable=protected-access if "Errno 28" in str(err): self.logger.fatal( '(while writing knownnodes to disk)' @@ -127,17 +129,11 @@ class singleCleaner(StoppableThread): "MainWindow", 'Alert: Your disk or data storage volume' ' is full. Bitmessage will now exit.'), - True) + True) )) - # FIXME redundant? - if shared.daemon or not state.enableGUI: + if shared.thisapp.daemon or not state.enableGUI: os._exit(1) -# # clear download queues -# for thread in threading.enumerate(): -# if thread.isAlive() and hasattr(thread, 'downloadQueue'): -# thread.downloadQueue.clear() - # inv/object tracking for connection in BMConnectionPool().connections(): connection.clean() @@ -150,7 +146,7 @@ class singleCleaner(StoppableThread): del state.discoveredPeers[k] except KeyError: pass - # TODO: cleanup pending upload / download + # ..todo:: cleanup pending upload / download gc.collect()