0

How can I make the socket run asynchronously?

This code doesn't work now. Nothing happens when the socket is called.

I need to call an asynchronous function internally. What should I do?

Here is my code:

socketio = SocketIO(application) 

@socketio.event
def message():
    ....
    ....
    ....
    await onUploadData()
1
  • Your code is incomplete. Commented Aug 8, 2024 at 23:08

2 Answers 2

1

just set async_handlers=True in SocketIO

async_handlers

If set to True, event handlers for a client are executed in separate threads. To run handlers for a client synchronously, set to False. The default is True.

See the documentation for more information

Sign up to request clarification or add additional context in comments.

Comments

0

Flask-SocketIO does not support asynchronous handlers. If you need to write an asynchronous Socket.IO application use python-socketio, which fully supports asyncio.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.