Skip to content

[Backport][v1.78.x][Python] Resolve absl::InitializeLog warning#41639

Merged
sergiitk merged 1 commit intogrpc:v1.78.xfrom
sreenithi:backport-1.78-absl_init_log_python
Feb 17, 2026
Merged

[Backport][v1.78.x][Python] Resolve absl::InitializeLog warning#41639
sergiitk merged 1 commit intogrpc:v1.78.xfrom
sreenithi:backport-1.78-absl_init_log_python

Conversation

@sreenithi
Copy link
Contributor

Backport of #39779 to v1.78.x.

Fixes #38703

After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.

This issue especially affects users who are indirect users of the gRPC Python library too, such as Gemini API users.

absl::InitializeLog() is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing.
The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on absl/log:initialize

Design gRFC for this: grpc/proposal#505

However, abseil-cpp currently doesn't allow absl::InitializeLog() to be called more than once, and will result in an error like:

[globals.cc : 104] RAW: absl::log_internal::SetTimeZone() has already been called

The changes in this PR may hence cause problems to a small percentage of users with a custom build that's linking directly against gRPC Cython code, and then call absl::InitializeLog() (directly or transitively).

To solve this problem, this PR also introduces a new environment variable GRPC_PYTHON_DISABLE_ABSL_INIT_LOG that will allow users to opt-out of this automatic abseil log initialization when set.

Fixes grpc#38703

After Core recently changed its logging system to use absl logging, gRPC python users started seeing the warning log
`WARNING: All log messages before absl::InitializeLog() is called are written to STDERR.`

This issue especially affects users who are indirect users of the gRPC Python  library too, such as Gemini API users.

`absl::InitializeLog()` is a C++ library that cannot directly be called in the Python layer. It is hence added in the Cython layer at the time of initializing.
The Python layer so far did not have a dependency on the absl library, hence this PR also adds an external dependency on `absl/log:initialize`

Design gRFC for this: grpc/proposal#505

Closes grpc#39779

COPYBARA_INTEGRATE_REVIEW=grpc#39779 from sreenithi:absl_init_log_python 59eb1e5
PiperOrigin-RevId: 869586957
@sreenithi sreenithi requested a review from sergiitk February 16, 2026 09:55
@sreenithi sreenithi self-assigned this Feb 16, 2026
@sreenithi sreenithi added the release notes: yes Indicates if PR needs to be in release notes label Feb 16, 2026
@sergiitk sergiitk merged commit 7139801 into grpc:v1.78.x Feb 17, 2026
56 of 60 checks passed
sergiitk added a commit to sergiitk/grpc that referenced this pull request Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bloat/none lang/Python release notes: yes Indicates if PR needs to be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants