connectionpool.py pylint fixes

This commit is contained in:
lakshyacis 2019-08-31 14:36:53 +05:30
parent 5521c16478
commit f1b6b16940
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
1 changed files with 29 additions and 22 deletions

View File

@ -1,3 +1,7 @@
"""
src/network/connectionpool.py
==================================
"""
import errno
import re
import socket
@ -20,6 +24,7 @@ from udp import UDPSocket
@Singleton
# pylint: disable=too-many-instance-attributes
class BMConnectionPool(object):
"""Pool of all existing connections"""
def __init__(self):
@ -113,7 +118,8 @@ class BMConnectionPool(object):
pass
connection.handle_close()
def getListeningIP(self):
@staticmethod
def getListeningIP():
"""What IP are we supposed to be listening on?"""
if BMConfigParser().safeGet(
"bitmessagesettings", "onionhostname").endswith(".onion"):
@ -154,7 +160,7 @@ class BMConnectionPool(object):
udpSocket = UDPSocket(host=bind, announcing=True)
self.udpSockets[udpSocket.listening.host] = udpSocket
def loop(self):
def loop(self): # pylint: disable=too-many-branches, too-many-statements
"""Main Connectionpool's loop"""
# defaults to empty loop if outbound connections are maxed
spawnConnections = False
@ -176,6 +182,7 @@ class BMConnectionPool(object):
'bitmessagesettings', 'onionhostname', '')):
acceptConnections = False
# pylint: disable=too-many-nested-blocks
if spawnConnections:
if not knownnodes.knownNodesActual:
helper_bootstrap.dns()
@ -253,7 +260,7 @@ class BMConnectionPool(object):
self.startListening()
else:
for bind in re.sub(
"[^\w.]+", " ",
'[^\w.]+', ' ', # pylint: disable=anomalous-backslash-in-string
BMConfigParser().safeGet('network', 'bind')
).split():
self.startListening(bind)
@ -263,7 +270,7 @@ class BMConnectionPool(object):
self.startUDPSocket()
else:
for bind in re.sub(
"[^\w.]+", " ",
'[^\w.]+', ' ', # pylint: disable=anomalous-backslash-in-string
BMConfigParser().safeGet('network', 'bind')
).split():
self.startUDPSocket(bind)