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

No longer handling CancelledError on protocol.run #240

Open
notmeta opened this issue May 18, 2023 · 0 comments · May be fixed by #241
Open

No longer handling CancelledError on protocol.run #240

notmeta opened this issue May 18, 2023 · 0 comments · May be fixed by #241

Comments

@notmeta
Copy link
Contributor

notmeta commented May 18, 2023

Since Python 3.8, aioamqp no longer catches and reraises asyncio.CancelledError in protocol.run, leading to delayed manual disconnections.

A fix is just handling both asyncio.CancelledError and Exception like so:

async def run(self):
    while not self.stop_now.is_set():
        try:
            await self.dispatch_frame()
        except exceptions.AmqpClosedConnection as exc:
            logger.info("Close connection")
            self.stop_now.set()

            self._close_channels(exception=exc)
        except (asyncio.CancelledError, Exception):
            logger.exception('error on dispatch')
@notmeta notmeta linked a pull request May 19, 2023 that will close this issue
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 a pull request may close this issue.

1 participant