class_singleCleaner.py quality fixes

This commit is contained in:
lakshyacis 2019-11-04 20:17:36 +05:30
parent 059e82e2a2
commit 80b2bc1c9a
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB

View File

@ -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()