stuff
This commit is contained in:
parent
b8db080960
commit
c1888e1cc3
10 changed files with 96 additions and 75 deletions
|
|
@ -44,6 +44,7 @@ def networking(q):
|
|||
|
||||
context = zmq.Context()
|
||||
connected = False
|
||||
a = None
|
||||
while not connected:
|
||||
socket = context.socket(zmq.PAIR)
|
||||
socket.connect("tcp://127.0.0.1:12345")
|
||||
|
|
@ -65,13 +66,16 @@ def networking(q):
|
|||
if msg['msg'] == "ping":
|
||||
send_msg(PONG_MSG, socket)
|
||||
timer = time.monotonic()
|
||||
|
||||
a = q.get(block=False)
|
||||
|
||||
if not a:
|
||||
a = q.get(block=False)
|
||||
if a:
|
||||
send_msg(a, socket)
|
||||
msg = get_msg(socket)
|
||||
if msg["msg"] == "ack":
|
||||
q.task_done()
|
||||
timer = time.monotonic()
|
||||
a = None
|
||||
self.q.task_done()
|
||||
else:
|
||||
connected = False
|
||||
|
||||
|
|
@ -80,17 +84,15 @@ class Counter:
|
|||
self.q = Queue()
|
||||
self.thread = threading.Thread(name="NetworkThread", target=networking, args=(self.q,))
|
||||
self.thread.start()
|
||||
self.q.join()
|
||||
|
||||
def request(self, flow):
|
||||
self.q.put(flow.get_state())
|
||||
self.q.put({'msg': 'request', 'flow': flow.get_state()})
|
||||
self.q.join()
|
||||
|
||||
def response(self, flow):
|
||||
self.q.put(flow.get_state())
|
||||
self.q.put({'msg': 'response', 'flow': flow.get_state()})
|
||||
self.q.join()
|
||||
|
||||
|
||||
addons = [
|
||||
Counter()
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue