Skip to content

How to emit(through call method) socket events from Celery tasks to clients connected via socketio.ASGIApp #1478

Closed Answered by miguelgrinberg
Trinkes asked this question in Q&A
Discussion options

You must be logged in to vote

The limitation here is that your Celery process is not a server process, so it is not set up to listen, which is necessary to receive the callback notifications that the call() method uses. Without the ability to listen, there is no way to do this.

The intention of this feature is to provide a quick way for a non-server process to send a message to a client through the server. If you need more than that, then you will have to use a different solution.

For example, your Celery job can connect to the FastAPI server as a Socket.IO client (using the Client or AsyncClient classes in the python-socketio package). Then it can talk to the server directly via WebSocket, which can listen for messag…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Trinkes
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants