reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
20.46k stars 1.18k forks source link

fix: do not create many redis subscriptions per token - fast yielding background #4419

Open benedikt-bartscher opened 6 days ago

benedikt-bartscher commented 6 days ago

@masenf any idea why fast yielding background tasks seem to lock up after some state updates?

benedikt-bartscher commented 5 days ago

@masenf i accidentally pushed unfinished changes and forgot to mention that the test needs to be run with redis

benedikt-bartscher commented 4 days ago

I pushed 389f4c7 which fixes the issue. Another idea to improve this even further: one shared subscription per token and worker (if I am not mistaken, we basically need to lock a token to a worker on redis, further locking can be done with asyncio). Reuse the subscription and release/garbage collect it after a delay.

However, I would merge this as-is, because it works and does not change the behavior much. I would then try implementing the other idea in a followup.