Remove state.shutdown or replaced with self._stopped from some network thread

This commit is contained in:
anand k 2024-05-13 07:23:11 +05:30
parent 3b36676793
commit 657c1de16b
No known key found for this signature in database
GPG Key ID: 515AC24FA525DDE0
4 changed files with 5 additions and 8 deletions

View File

@ -4,7 +4,6 @@ Announce addresses as they are received from other hosts
from six.moves import queue from six.moves import queue
# magic imports! # magic imports!
import state
import connectionpool import connectionpool
from helper_random import randomshuffle from helper_random import randomshuffle
from protocol import assembleAddrMessage from protocol import assembleAddrMessage
@ -18,7 +17,7 @@ class AddrThread(StoppableThread):
name = "AddrBroadcaster" name = "AddrBroadcaster"
def run(self): def run(self):
while not state.shutdown: while not self._stopped:
chunk = [] chunk = []
while True: while True:
try: try:

View File

@ -20,7 +20,7 @@ class AnnounceThread(StoppableThread):
def run(self): def run(self):
lastSelfAnnounced = 0 lastSelfAnnounced = 0
while not self._stopped and state.shutdown == 0: while not self._stopped:
processed = 0 processed = 0
if lastSelfAnnounced < time.time() - self.announceInterval: if lastSelfAnnounced < time.time() - self.announceInterval:
self.announceSelf() self.announceSelf()

View File

@ -2,7 +2,6 @@
A thread to handle network concerns A thread to handle network concerns
""" """
import network.asyncore_pollchoose as asyncore import network.asyncore_pollchoose as asyncore
import state
import connectionpool import connectionpool
from queues import excQueue from queues import excQueue
from threads import StoppableThread from threads import StoppableThread
@ -14,7 +13,7 @@ class BMNetworkThread(StoppableThread):
def run(self): def run(self):
try: try:
while not self._stopped and state.shutdown == 0: while not self._stopped:
connectionpool.pool.loop() connectionpool.pool.loop()
except Exception as e: except Exception as e:
excQueue.put((self.name, e)) excQueue.put((self.name, e))

View File

@ -5,7 +5,6 @@ import errno
import Queue import Queue
import socket import socket
import state
import connectionpool import connectionpool
from network.advanceddispatcher import UnknownStateError from network.advanceddispatcher import UnknownStateError
from queues import receiveDataQueue from queues import receiveDataQueue
@ -19,13 +18,13 @@ class ReceiveQueueThread(StoppableThread):
super(ReceiveQueueThread, self).__init__(name="ReceiveQueue_%i" % num) super(ReceiveQueueThread, self).__init__(name="ReceiveQueue_%i" % num)
def run(self): def run(self):
while not self._stopped and state.shutdown == 0: while not self._stopped:
try: try:
dest = receiveDataQueue.get(block=True, timeout=1) dest = receiveDataQueue.get(block=True, timeout=1)
except Queue.Empty: except Queue.Empty:
continue continue
if self._stopped or state.shutdown: if self._stopped:
break break
# cycle as long as there is data # cycle as long as there is data