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

fix: unsubscribing twice from the same pubsub channel raises a KeyError exception #255

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

ilolis
Copy link
Contributor

@ilolis ilolis commented Dec 19, 2024

Trying to unsubscribe twice from the same pubsub channel raises a KeyError exception upon calling get_message().

Steps to reproduce:

import asyncio
import coredis


async def test():
    r = coredis.Redis.from_url("redis://127.0.0.1:6379")
    p = r.pubsub()

    await p.subscribe('channel')
    for _ in range(0, 10):
        await p.get_message(timeout=0.01)

    await p.unsubscribe('channel')
    await asyncio.sleep(0.1)
    await p.get_message()

    # unsub again
    await p.unsubscribe('channel')
    await asyncio.sleep(0.1)

    # the below will throw exception
    await p.get_message()


asyncio.run(test())

@alisaifee alisaifee merged commit 66920cd into alisaifee:master Dec 19, 2024
56 checks passed
@alisaifee
Copy link
Owner

Thanks! Added a corresponding test case for this scenario here: c856d29

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

Successfully merging this pull request may close these issues.

2 participants