add zmq
This commit is contained in:
21
zmq/consumer.py
Normal file
21
zmq/consumer.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
from datetime import datetime
|
||||
import zmq
|
||||
|
||||
|
||||
DATETIMES=[]
|
||||
|
||||
|
||||
context = zmq.Context()
|
||||
socket = context.socket(zmq.SUB)
|
||||
socket.connect("tcp://127.0.0.1:5559")
|
||||
|
||||
socket.setsockopt_string(zmq.SUBSCRIBE, "test")
|
||||
|
||||
try:
|
||||
while True:
|
||||
m = socket.recv_string()
|
||||
DATETIMES.append(datetime.now())
|
||||
except Exception:
|
||||
socket.close()
|
||||
print(DATETIMES)
|
||||
Reference in New Issue
Block a user