According to documentation when emitting from external processes one can instantiate a SocketIO instance (given one is using a message queue) and emit using that.
socketio = SocketIO(message_queue='redis://')
socketio.emit('my event', {'data': 'foo'}, namespace='/test')
However, another way is to cause an emit from the external process might be to fake a POST request to the server and and emit from that event handler.
def extenal_process():
post('SERVER/finished', json=meta)
@app.route('/finished/', methods=['POST'])
def event():
userid,data = request.get_json()
socketio.emit('celerystatus', data, namespace='/events', room=userid)
return 'ok'
I was wondering if there is any downside to using the second approach or if you recommend both approaches?
While I do prefer the former approach and realize that faking POST requests might hog the server, having a separate message queue and instantiating a new object every time might also hog the celery worker (my external process).
Thanks
According to documentation when emitting from external processes one can instantiate a
SocketIOinstance (given one is using a message queue) and emit using that.However, another way is to cause an emit from the external process might be to fake a POST request to the server and and emit from that event handler.
I was wondering if there is any downside to using the second approach or if you recommend both approaches?
While I do prefer the former approach and realize that faking POST requests might hog the server, having a separate message queue and instantiating a new object every time might also hog the celery worker (my external process).
Thanks