def listen_thread():
ctx = zmq.Context()
# Reply - act as server
socket = ctx.socket(zmq.REP)
socket.bind('tcp://*:%s' % config.ZEROMQ_PORT)
while True:
request = socket.recv()
print('ZEROMQ request -', request)
socket.send('OK')
if request == 'KILL':
socket.close()
print('Socket closed.')
break
with webapp.app_context():
data = json.loads(request)
print('Sending to SocketIO ...')
socketio.emit(
'new_update',
data['msg'] + ' at ' + data['timestamp'],
namespace='/browser',
)
zeromq.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录