2017-07-05 08:57:44 +02:00
|
|
|
import Queue
|
|
|
|
|
|
|
|
from helper_threading import StoppableThread
|
|
|
|
from network.connectionpool import BMConnectionPool
|
|
|
|
from queues import addrQueue
|
|
|
|
import state
|
|
|
|
|
2019-08-01 13:37:26 +02:00
|
|
|
|
|
|
|
class AddrThread(StoppableThread):
|
|
|
|
name = "AddrBroadcaster"
|
2017-07-05 08:57:44 +02:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
while not state.shutdown:
|
|
|
|
chunk = []
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
data = addrQueue.get(False)
|
|
|
|
chunk.append((data[0], data[1]))
|
2017-07-08 18:02:47 +02:00
|
|
|
if len(data) > 2:
|
|
|
|
source = BMConnectionPool().getConnectionByAddr(data[2])
|
2017-07-05 08:57:44 +02:00
|
|
|
except Queue.Empty:
|
|
|
|
break
|
2017-07-08 18:02:47 +02:00
|
|
|
except KeyError:
|
|
|
|
continue
|
2017-07-05 08:57:44 +02:00
|
|
|
|
2019-08-01 13:37:26 +02:00
|
|
|
# finish
|
2017-07-05 08:57:44 +02:00
|
|
|
|
|
|
|
addrQueue.iterate()
|
2017-10-19 08:56:48 +02:00
|
|
|
for i in range(len(chunk)):
|
|
|
|
addrQueue.task_done()
|
2017-07-05 08:57:44 +02:00
|
|
|
self.stop.wait(1)
|