-
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postgres backend: handle connection loss #66
base: master
Are you sure you want to change the base?
Conversation
Hi @asafc - this was a good start. |
Hi @dariosky, I don't believe automatically reconnecting is a good idea: when connection is loss messages could be missed, On our use case - disconnecting (marked by ending the iterator) is more than enough (then the caller can reconnect). WDYT? |
Having an on_reconnect parameter is a good idea - so the caller can handle the eventual gap-filling... |
Not sure I understand - have you pushed that fix? (or plan on pushing it?) |
I didn't (I asked above if it can be useful) - let me add it here :) |
See here: permitio#4 |
for queue in list(self._subscribers.get(event.channel, [])): | ||
await queue.put(event) | ||
|
||
# Ubsubscribe all | ||
for queue in sum([list(qs) for qs in self._subscribers.values()], []): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Unsubscribe all
for queue_set in self._subscribers.values():
for queue in queue_set:
await queue.put(None)
Seems like a lot less wasteful / clear what's going on.
As far as I know, you can loop over sets directly in python, no need
to convert to a list.
This requires extra testing. Will not include in 0.3 |
This bugfix handle a situation where broadcaster does not detect the Postgres backend terminating the connection.
A user of Broadcaster will not be able to handle disconnects in their code.
i.e: the next loop will not exit:
when either:
idle_session_timeout
oridle_in_transaction_session_timeout
(see here)