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: make atexit registration conditional on background transport #978

Closed
wants to merge 1 commit into from

Conversation

otorreno
Copy link

@otorreno otorreno commented Mar 7, 2025

The background transport fails on Python 3.12 when working with gRPC in case there are messages in the queue when the Python interpreter exits. Making the registration of the atexit callback conditional so that users can circumvent this error by explicitly stopping the logging when their application terminates.

We can consider making the default value depend on the Python version at runtime, but it was decided to not change the default behaviour, regardless of the Python version.

Fixes #850 and #855 (if users would setup the logging disabling the atexit hook).

The background transport fails on Python 3.12 when working with gRPC in case
there are messages in the queue when the Python interpreter exits. Making the
registration of the atexit callback conditional so that users can circumvent this
error by explicitly stopping the logging when their application terminates.

We can consider making the default value depend on the Python version at
runtime, but it was decided to not change the default behaviour, regardless
of the Python version.

Fixes googleapis#850 and googleapis#855 (if users would setup the logging disabling the atexit
hook)
@otorreno otorreno requested review from a team as code owners March 7, 2025 11:13
@otorreno otorreno requested a review from daniel-sanche March 7, 2025 11:13
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: logging Issues related to the googleapis/python-logging API. labels Mar 7, 2025
@gkevinzheng
Copy link
Contributor

Hi @otorreno,

I had a PR last year for fixing the same issue by adding various flusing and closing methods to the handlers (#917) before I started on other work, and never picked the PR back up. I'll take a look at that old PR and try to merge it in.

@otorreno
Copy link
Author

otorreno commented Mar 8, 2025

Hi @otorreno,

I had a PR last year for fixing the same issue by adding various flusing and closing methods to the handlers (#917) before I started on other work, and never picked the PR back up. I'll take a look at that old PR and try to merge it in.

Ack. Is there any way I can help @gkevinzheng ? This is blocking the migration of our AppEngine-deployed app to 3.12

@otorreno otorreno deleted the fix/atexit_conditional branch March 11, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/python-logging API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RuntimeError: can't create new thread at interpreter shutdown
2 participants