Python keep socket connection alive -


i have python2.7 server flask, flask_socketio, uwsgi

here code sample:

from fit.app import app flask_socketio import socketio, emit fit.query import getesvalue  socketio = socketio(app)  @socketio.on('get_client_info') def handle_message(data):     client = data["client"]     p_id = data["p_id"]     esvalues = getesvalue(client, none, p_id)     emit('client_results', {"client": client, "data": esvalues})   if __name__ == "__main__":     socketio.run(app) 

esvalues = getesvalue(client, none, p_id) high weight operation can take 15 minutes.

but finished, i'm trying send results client side , receive following errors:

receive error traceback (most recent call last): file "venv/local/lib/python2.7/site-packages/engineio/socket.py", line 209, in _websocket_hand ler self.receive(pkt) file "venv/local/lib/python2.7/site-packages/engineio/socket.py", line 53, in receive self.send(packet.packet(packet.pong, pkt.data)) file "venv/local/lib/python2.7/site-packages/engineio/socket.py", line 67, in send raise ioerror('socket closed') ioerror: socket closed

and one:

error: (9, 'bad file descriptor') wed jul 26 13:29:28 2017 greenlet @ 0x7f4ba547be10: select_greenlet_runner(9, )> failed error

i think i'm trying use socket connection has been closed. how can keep alive until 15 minutes task finished ?

the issue can resolved setting timeout option when starting server. can achieved changing line:

socketio.run(app) 

to

socketio.run(app, ping_timeout=3600) 

change 3600 match reuquirements


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -