From 657c1de16b3481506e609f991a54f104f4fef831 Mon Sep 17 00:00:00 2001 From: anand k Date: Mon, 13 May 2024 07:23:11 +0530 Subject: [PATCH] Remove state.shutdown or replaced with self._stopped from some network thread --- src/network/addrthread.py | 3 +-- src/network/announcethread.py | 2 +- src/network/networkthread.py | 3 +-- src/network/receivequeuethread.py | 5 ++--- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/network/addrthread.py b/src/network/addrthread.py index 74a5d744..a0e869e3 100644 --- a/src/network/addrthread.py +++ b/src/network/addrthread.py @@ -4,7 +4,6 @@ Announce addresses as they are received from other hosts from six.moves import queue # magic imports! -import state import connectionpool from helper_random import randomshuffle from protocol import assembleAddrMessage @@ -18,7 +17,7 @@ class AddrThread(StoppableThread): name = "AddrBroadcaster" def run(self): - while not state.shutdown: + while not self._stopped: chunk = [] while True: try: diff --git a/src/network/announcethread.py b/src/network/announcethread.py index 003eb092..cd3eed2a 100644 --- a/src/network/announcethread.py +++ b/src/network/announcethread.py @@ -20,7 +20,7 @@ class AnnounceThread(StoppableThread): def run(self): lastSelfAnnounced = 0 - while not self._stopped and state.shutdown == 0: + while not self._stopped: processed = 0 if lastSelfAnnounced < time.time() - self.announceInterval: self.announceSelf() diff --git a/src/network/networkthread.py b/src/network/networkthread.py index dc5f616f..640d47a1 100644 --- a/src/network/networkthread.py +++ b/src/network/networkthread.py @@ -2,7 +2,6 @@ A thread to handle network concerns """ import network.asyncore_pollchoose as asyncore -import state import connectionpool from queues import excQueue from threads import StoppableThread @@ -14,7 +13,7 @@ class BMNetworkThread(StoppableThread): def run(self): try: - while not self._stopped and state.shutdown == 0: + while not self._stopped: connectionpool.pool.loop() except Exception as e: excQueue.put((self.name, e)) diff --git a/src/network/receivequeuethread.py b/src/network/receivequeuethread.py index cad1376c..10f2acea 100644 --- a/src/network/receivequeuethread.py +++ b/src/network/receivequeuethread.py @@ -5,7 +5,6 @@ import errno import Queue import socket -import state import connectionpool from network.advanceddispatcher import UnknownStateError from queues import receiveDataQueue @@ -19,13 +18,13 @@ class ReceiveQueueThread(StoppableThread): super(ReceiveQueueThread, self).__init__(name="ReceiveQueue_%i" % num) def run(self): - while not self._stopped and state.shutdown == 0: + while not self._stopped: try: dest = receiveDataQueue.get(block=True, timeout=1) except Queue.Empty: continue - if self._stopped or state.shutdown: + if self._stopped: break # cycle as long as there is data -- 2.45.1