Hacker News new | ask | show | jobs
by axitanull 3033 days ago
>These are pretty big Flask apps too, which have thousands of lines of code, dozens of packages, tons of assets and require running Celery, Postgres, Redis, etc..

I was trying to create a new project last month trying to put all of these together. One thing that I was stuck in was putting these together:

- non-single-thread-Flask

- Redis pub-sub, subscribe to listen to a channel

- and websocket (such as socket.io) upon receiving redis sub message, pushing the message to client side.

I found out that this was a non-trivial thing to do, as redis subscribe is a blocking function, and I was not able to push websocket message from redis subscribe callback. I wonder how did they do that, if any?

2 comments

In the past, when I needed websockets in a Flask app I used Faye (backed by Redis) for the websocket back-end.

It was really easy to set up with Docker as it just becomes another container in your Compose file.

Nowadays I would just use Pusher.

Fanout/Pushpin works here as does having an aiohttp wrapped WSGI Flask app.