I am trying to setup a zmq
socket inside a worker-task in python-rq
.
If I create the context
inside the task function:
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' )
)
the pub.send()
call does nothing.