Skip to content
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

KeyError triggered by ConnectionError: Connection closed by server. #142

Open
JoseKilo opened this issue Sep 23, 2024 · 0 comments
Open

Comments

@JoseKilo
Copy link

Hi maintainers, thank you for the package !

This line can fail with a ConnectionError, at least when using the Redis backend, possibly others too:

await self._backend.subscribe(channel)

When that happens, queue is never added to self._subscribers[channel].

But the finally block will try to remove it nonetheless, causing a KeyError and hiding the original issue:

self._subscribers[channel].remove(queue)

Possible solutions:

  • Using discard instead of remove
  • maybe moving the _backend.subscribe call outside the try block: when that call fails you can probably skip self._backend.unsubscribe. You'd still need to put a None in the queue though.

I could prepare a PR with any of those if they make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant