Skip to content

add try/finally to ensure we exit on close error #2304

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

JonathanSerafini
Copy link
Contributor

Description

When closing the consumer during a consume operation the consumer may throw an exception
which is neither handled not reported.

This is especially problematic when this is as a result of a SystemExit exception where
we are expecting the application to shutdown. Currently, when this situation occurs, the application
ends up in an inconsistent state where the consumer may be shutdown and no longer consuming,
yet the application remains up.

As an initial patch for this, we call the app.exit() within a try/finally block.

In my situation, the underlying root cause was a CancelledError thrown deep within aiokafka:
aio-libs/aiokafka#647

Fixes # (issue number)

Type of change

Please delete options that are not relevant.

  • Bug fix (a non-breaking change that resolves an issue)

Checklist

  • [x ] My code adheres to the style guidelines of this project (scripts/lint.sh shows no errors)
  • [x ] I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation
  • [x ] My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix or the functionality of my new feature
  • Both new and existing unit tests pass successfully on my local environment by running scripts/test-cov.sh
  • I have ensured that static analysis tests are passing by running scripts/static-analysis.sh
  • I have included code examples to illustrate the modifications

@Lancetnik Lancetnik added this pull request to the merge queue Jun 18, 2025
Merged via the queue into ag2ai:main with commit 7c5dffc Jun 18, 2025
32 checks passed
@CLAassistant
Copy link

CLAassistant commented Jun 18, 2025

CLA assistant check
All committers have signed the CLA.

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.

3 participants