Xandaaah
Xandaaah

Reputation: 71

Python flask_socketio + pty recieve handler not being called

So, I have some code for a flask_socketio virtual console. I can see the output, but when to send in a command, recv isn't called.

Code:

@socketio.on('connect')
def test_connect(auth: str):
    def read_handler(fd: int):
        emit('data', os.read(fd, 1024), broadcast=True)
    def write_handler(fd: int):
        @socketio.on('data')
        def recv(data: str):
            emit('data', data, broadcast=True)
            os.write(fd, data.encode())
    print('connect', auth)
    pty.spawn("/bin/sh", read_handler, write_handler)
    #disconnect(auth)

Upvotes: 0

Views: 14

Answers (0)

Related Questions