go-pera
go-pera

Reputation: 31

Websockets in python Quart with multiple workers?

Websockets in python Quart with multiple workers?

Is there a solution to broadcast a message when my app is launched across multiple workers - for example using hypercorn?

I'm currently launching my app like this:

$ hypercorn -b 127.0.0.1:8000 -w 4 wsgi:app

But the documented solution is to keep the connected clients in memory, with no way to broadcast to others that subscribed to the same event.

Any ideas? I was thinking to use Redis to achieve this, but I would like a simpler solution.

Upvotes: 3

Views: 1099

Answers (1)

pgjones
pgjones

Reputation: 7039

I don't think there is a simpler solution than Redis (or similar third party tool) for this.

It is possible to run Hypercorn with memory shared across the workers, but it isn't simple to setup. Start here if you want to try this. At some point though you may have workers across multiple machines, in which case shared memory no longer works.

Upvotes: 1

Related Questions