我有燒瓶,flask_socketio一個Python2.7服務器,uwsgiPython的保持插座連接活着
下面是一個代碼示例:
from fit.app import app
from flask_socketio import SocketIO, emit
from 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(客戶端,無,P_ID)是一項高重量操作,可能需要長達15分鐘。
但隨後成功完成,我試圖將結果發送到客戶端,並收到以下錯誤:
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 is closed') IOError: Socket is closed
,然後這一個:
error: (9, 'Bad file descriptor') Wed Jul 26 13:29:28 2017 Greenlet at 0x7f4ba547be10: select_greenlet_runner(9,)> failed with error
我認爲我」 m試圖使用已關閉的套接字連接。 如何在15分鐘任務完成之前保持活動狀態?
請您提供它的Python版本:它可以通過改變這條線能實現嗎? –
我是downvoting,因爲答案沒有解釋任何東西,實際上沒有具體做什麼OP問 –
@ВласБоюс這可能有助於 –