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

Re-connect after getting StreamTerminatedError #169

Open
ahmdrz opened this issue Feb 7, 2023 · 0 comments
Open

Re-connect after getting StreamTerminatedError #169

ahmdrz opened this issue Feb 7, 2023 · 0 comments

Comments

@ahmdrz
Copy link

ahmdrz commented Feb 7, 2023

Is there any way to reconnect after getting StreamTerminatedError?

max_retries = 5
for retries in range(max_retries):
    try:
        await stream.send_message(...)
        break
    except StreamTerminatedError as e:
        if (retries + 1) == max_retries:
            raise e
        # Reconnect here
        await asyncio.sleep(10)

I wanted to reconnect to the channel and try sending a message again without creating another context or whole stream connection.
Are there any tricks? I just wanted to ensure about sending a specific message.

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