我正在尝试在zmq中的worker任务中设置一个python-rq套接字。
如果我在任务函数中创建context:
def push( user, task_id, data ):
"""Push message to `user` over websocket.
"""
ctx = zmq.Context()
pub = ctx.socket( zmq.PUB )
pub.connect( 'ipc:///tmp/message_flow_in' )
pub.send( b"0 " + json.dumps( {'username': user,
'id': task_id,
'data': data
}
).encode( 'utf-8' )
)pub.send()调用什么也不做。
发布于 2016-05-23 22:34:21
所以我不知道python,所以这可能是不正确的,但是它非常类似于我在c++中使用zeromq时遇到的一个问题,所以:
当您调用send消息时,它将复制到套接字/上下文中的缓冲区,以便稍后由上下文发送。因此,当您的函数返回并且本地套接字/上下文超出作用域时,该消息可能会在由上下文发送消息之前被删除。
https://stackoverflow.com/questions/37396078
复制相似问题