在python-socketio中使用subprocess.Popen的问题.

现在可以确认towork函数能够成功创建线程,且前端能收到ready to work
但是在执行完popen后在调用socketio.emit就没有反应了

后端flask如下

 @socketio.on('work')
def towork():
    t=threading.Thread(target=test)
    t.start()

def test():
    socketio.emit('listen',{'res':'ready to work'})
    cmd='dir'
    out=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
    status=out.wait()
    if status==0:
        socketio.emit('listen',{'res':'sucess'})
    else:
        socketio.emit('listen',{'res':'failed'})

前端H5,如下

 socket.on("listen",function(msg){
    $('#show').append(`<p>{msg.res}</p>`);
});

https://stackoverflow.com/questions/34599578/using-popen-in-a-thread-blocks-every-incoming-flask-socketio-request