Skip to content

[Python] Align GRPC_ENABLE_FORK_SUPPORT env defaults in core and python#41455

Closed
sergiitk wants to merge 2 commits intogrpc:masterfrom
sergiitk:fix/py/fork-defaults
Closed

[Python] Align GRPC_ENABLE_FORK_SUPPORT env defaults in core and python#41455
sergiitk wants to merge 2 commits intogrpc:masterfrom
sergiitk:fix/py/fork-defaults

Conversation

@sergiitk
Copy link
Member

@sergiitk sergiitk commented Jan 20, 2026

In the core, the default value of the GRPC_ENABLE_FORK_SUPPORT environment variable is determined by the value of the GRPC_ENABLE_FORK_SUPPORT_DEFAULT macro, which is by default derived from the value of the GRPC_ENABLE_FORK_SUPPORT macro. Python sets GRPC_ENABLE_FORK_SUPPORT, so the feature is enabled there by default. However, Python also reads the value of the GRPC_ENABLE_FORK_SUPPORT environment variable and sets its own default in fork_posix.pyx.pxi, and the feature is disabled there by default. The result is a mixed state that causes problems.

This change fixes that by disabling the feature by default in both places. In the long run we want to enable it by default everywhere, but for now we don't have confidence in its stability.

@sergiitk sergiitk self-assigned this Jan 20, 2026
@sergiitk sergiitk added the release notes: no Indicates if PR should not be in release notes label Jan 20, 2026
@sergiitk sergiitk marked this pull request as ready for review January 22, 2026 20:48
@sergiitk sergiitk requested a review from murgatroid99 January 22, 2026 20:49
@sergiitk
Copy link
Member Author

Potentially solves #37710.

setup.py Outdated
#
# Important! This must by in sync with the default value for the
# GRPC_ENABLE_FORK_SUPPORT env var parsed in fork_posix.pyx.pxi
("GRPC_ENABLE_FORK_SUPPORT_DEFAULT", 0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value should be "false". See

#ifdef GRPC_ENABLE_FORK_SUPPORT
#ifndef GRPC_ENABLE_FORK_SUPPORT_DEFAULT
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT true
#endif // !defined(GRPC_ENABLE_FORK_SUPPORT_DEFAULT)
#else
#define GRPC_ENABLE_FORK_SUPPORT_DEFAULT false
#endif // GRPC_ENABLE_FORK_SUPPORT
for comparison.

Copy link
Member Author

@sergiitk sergiitk Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did work (tested locally by reading the config_var value from the python layer), but I agree, using a bool makes more sense. Thanks.

@sergiitk sergiitk requested a review from murgatroid99 January 22, 2026 21:07
@sergiitk sergiitk deleted the fix/py/fork-defaults branch January 28, 2026 05:36
sergiitk added a commit to sergiitk/grpc that referenced this pull request Feb 10, 2026
…on (grpc#41455)

In the core, the default value of the `GRPC_ENABLE_FORK_SUPPORT` environment variable is determined by the value of the `GRPC_ENABLE_FORK_SUPPORT_DEFAULT` macro, which is by default derived from the value of the `GRPC_ENABLE_FORK_SUPPORT` macro. Python sets `GRPC_ENABLE_FORK_SUPPORT`, so the feature is enabled there by default. However, Python also reads the value of the `GRPC_ENABLE_FORK_SUPPORT` environment variable and sets its own default in `fork_posix.pyx.pxi`, and the feature is disabled there by default. The result is a mixed state that causes problems.

This change fixes that by disabling the feature by default in both places. In the long run we want to enable it by default everywhere, but for now we don't have confidence in its stability.

Closes grpc#41455

COPYBARA_INTEGRATE_REVIEW=grpc#41455 from sergiitk:fix/py/fork-defaults 73be72d
PiperOrigin-RevId: 859928704
sergiitk added a commit that referenced this pull request Feb 10, 2026
…ts in core and python (#41588)

Backport of #41455 to v1.78.x.
---
In the core, the default value of the `GRPC_ENABLE_FORK_SUPPORT`
environment variable is determined by the value of the
`GRPC_ENABLE_FORK_SUPPORT_DEFAULT` macro, which is by default derived
from the value of the `GRPC_ENABLE_FORK_SUPPORT` macro. Python sets
`GRPC_ENABLE_FORK_SUPPORT`, so the feature is enabled there by default.
However, Python also reads the value of the `GRPC_ENABLE_FORK_SUPPORT`
environment variable and sets its own default in `fork_posix.pyx.pxi`,
and the feature is disabled there by default. The result is a mixed
state that causes problems.

This change fixes that by disabling the feature by default in both
places. In the long run we want to enable it by default everywhere, but
for now we don't have confidence in its stability.
@murgatroid99 murgatroid99 mentioned this pull request Mar 2, 2026
sergiitk added a commit to sergiitk/grpc that referenced this pull request Mar 2, 2026
copybara-service bot pushed a commit that referenced this pull request Mar 3, 2026
…and python (#41455)" (#41769)

- This reverts commit ee658b2.
- This changed caused #41725 in v1.78.1, which was yanked as the result (ref b/487190834).
- Tracking ticket for the follow-up investigation and fix: #41768.
- Reopens #37710.

Closes #41769

COPYBARA_INTEGRATE_REVIEW=#41769 from sergiitk:revert/fix/py/fork-defaults 01564d6
PiperOrigin-RevId: 877735128
sergiitk added a commit to sergiitk/grpc that referenced this pull request Mar 9, 2026
…and python (grpc#41455)" (grpc#41769)

- This reverts commit ee658b2.
- This changed caused grpc#41725 in v1.78.1, which was yanked as the result (ref b/487190834).
- Tracking ticket for the follow-up investigation and fix: grpc#41768.
- Reopens grpc#37710.

Closes grpc#41769

COPYBARA_INTEGRATE_REVIEW=grpc#41769 from sergiitk:revert/fix/py/fork-defaults 01564d6
PiperOrigin-RevId: 877735128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/Python release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants