2017-07-05 08:57:44 +02:00
|
|
|
import Queue
|
|
|
|
import threading
|
|
|
|
|
|
|
|
import addresses
|
|
|
|
from helper_threading import StoppableThread
|
|
|
|
from network.connectionpool import BMConnectionPool
|
|
|
|
from queues import addrQueue
|
|
|
|
import protocol
|
|
|
|
import state
|
|
|
|
|
|
|
|
class AddrThread(threading.Thread, StoppableThread):
|
|
|
|
def __init__(self):
|
2017-07-10 07:05:50 +02:00
|
|
|
threading.Thread.__init__(self, name="AddrBroadcaster")
|
2017-07-05 08:57:44 +02:00
|
|
|
self.initStop()
|
2017-07-10 07:05:50 +02:00
|
|
|
self.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
|
|
|
|
|
|
|
#finish
|
|
|
|
|
|
|
|
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)
|