Skip to content

chore: log warning when process is forked without polling thread - #24

Open
yangguoif wants to merge 3 commits into
mainfrom
yangguo/warning-when-multi-processing
Open

yangguoif wants to merge 3 commits into
mainfrom
yangguo/warning-when-multi-processing

Conversation

@yangguoif

@yangguoif yangguoif commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Background

This PR is originated from a comment in previous PR. On consumer side, If the provider is setup before calling fork(), the flags will be stale in the new process because the polling process runs in a background thread, which is not copied across process forking.

Result

As discussed in the comment above, this PR checks pid in the evaluation, to ensure that it is the same process ID as the polling thread is in, otherwise log a warning. This warning is only logged once per process.

Before

I have reproduced locally with gunicorn with --preload, which imports the app before forking. After updating the flag value in Octopus, and sending curl request to evaluate, no warning is logged and the flag value is not updated in evaluation.

Screenshot 2026-11-26 at 3 55 20 PM

After

With the PR's change, we can see the warning log when receiving evaluation request, although the value is still stale.

Screenshot 2026-11-26 at 3 58 24 PM

By applying the suggestion in README, the flag value is updated

Screen.Recording.2026-11-26.at.4.06.34.PM.mov

@yangguoif
yangguoif requested a review from a team as a code owner November 26, 2026 03:07
@yangguoif yangguoif changed the title chore: warning when process is forked chore: log warning when process is forked Nov 26, 2026
@yangguoif yangguoif changed the title chore: log warning when process is forked chore: log warning when process is forked without polling thread Nov 26, 2026
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.

1 participant