You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "shunping (via GitHub)" <gi...@apache.org> on 2026/05/12 01:55:53 UTC
[PR] Make SubprocessServer shared cache purging idempotent [beam]
shunping opened a new pull request, #38455:
URL: https://github.com/apache/beam/pull/38455
Avoids ValueError during atexit shutdown when a cached subprocess server was already cleaned up earlier. Right now, such exception is already ignored because it happens at atexit.
Example traceback (https://github.com/apache/beam/actions/runs/25705764624/job/75475412939):
```
Exception ignored in atexit callback: <bound method StopOnExitJobServer.stop of <apache_beam.runners.portability.job_server.StopOnExitJobServer object at 0x7f60831f4da0>>
Traceback (most recent call last):
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/runners/portability/job_server.py", line 98, in stop
self._job_server.stop()
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/runners/portability/job_server.py", line 132, in stop
return self._server.stop()
^^^^^^^^^^^^^^^^^^^
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/utils/subprocess_server.py", line 254, in stop
self.stop_process()
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/utils/subprocess_server.py", line 259, in stop_process
self._cache.purge(self._owner_id)
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/utils/subprocess_server.py", line 94, in purge
raise ValueError(f"{owner} not in {self._live_owners}")
ValueError: 267 not in set()
Exception ignored in atexit callback: <bound method StopOnExitJobServer.stop of <apache_beam.runners.portability.job_server.StopOnExitJobServer object at 0x7f603aeb8ef0>>
Traceback (most recent call last):
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/runners/portability/job_server.py", line 98, in stop
self._job_server.stop()
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/runners/portability/job_server.py", line 132, in stop
return self._server.stop()
^^^^^^^^^^^^^^^^^^^
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/utils/subprocess_server.py", line 254, in stop
self.stop_process()
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/utils/subprocess_server.py", line 259, in stop_process
self._cache.purge(self._owner_id)
File "/runner/_work/beam/beam/sdks/python/test-suites/tox/py312/build/srcs/sdks/python/target/.tox-py312/py312/lib/python3.12/site-packages/apache_beam/utils/subprocess_server.py", line 94, in purge
raise ValueError(f"{owner} not in {self._live_owners}")
ValueError: 2 not in set()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make SubprocessServer shared cache purging idempotent [beam]
Posted by "shunping (via GitHub)" <gi...@apache.org>.
shunping merged PR #38455:
URL: https://github.com/apache/beam/pull/38455
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make SubprocessServer shared cache purging idempotent [beam]
Posted by "shunping (via GitHub)" <gi...@apache.org>.
shunping commented on code in PR #38455:
URL: https://github.com/apache/beam/pull/38455#discussion_r3227084242
##########
sdks/python/apache_beam/utils/subprocess_server.py:
##########
@@ -91,7 +91,11 @@ def purge(self, owner):
to_delete = []
with self._lock:
if owner not in self._live_owners:
- raise ValueError(f"{owner} not in {self._live_owners}")
+ _LOGGER.warning(
+ "Subprocess owner %s already purged. If this occurs during atexit "
+ "shutdown, the subprocess was already cleaned up earlier.",
+ owner)
+ return
Review Comment:
This is not common during shutdown. The situation is harmless but would be great to log it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make SubprocessServer shared cache purging idempotent [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #38455:
URL: https://github.com/apache/beam/pull/38455#discussion_r3223526357
##########
sdks/python/apache_beam/utils/subprocess_server.py:
##########
@@ -91,7 +91,11 @@ def purge(self, owner):
to_delete = []
with self._lock:
if owner not in self._live_owners:
- raise ValueError(f"{owner} not in {self._live_owners}")
+ _LOGGER.warning(
+ "Subprocess owner %s already purged. If this occurs during atexit "
+ "shutdown, the subprocess was already cleaned up earlier.",
+ owner)
+ return
Review Comment:

The log message is quite verbose and specific to `atexit` shutdown. While helpful for debugging the reported issue, it might be noisy if this occurs in other contexts. Additionally, logging while holding a lock (`self._lock`) can occasionally lead to performance bottlenecks or deadlocks depending on the logging handler's implementation. Consider moving the log call outside the lock block or reducing its severity to `DEBUG` if this is a common and expected occurrence during shutdown.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make SubprocessServer shared cache purging idempotent [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38455:
URL: https://github.com/apache/beam/pull/38455#issuecomment-4427412334
Assigning reviewers:
R: @jrmccluskey for label python.
Note: If you would like to opt out of this review, comment `assign to next reviewer`.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make SubprocessServer shared cache purging idempotent [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #38455:
URL: https://github.com/apache/beam/pull/38455#issuecomment-4427088164
## Summary of Changes
Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses an issue where subprocess servers would raise a ValueError during atexit shutdown if the cache had already been cleaned up. By making the purge operation idempotent and logging a warning instead of failing, the system now handles redundant cleanup calls gracefully, ensuring cleaner process termination.
### Highlights
* **Idempotent Cache Purging**: Modified the SubprocessServer cache purging logic to be idempotent, preventing ValueError exceptions during atexit shutdown.
* **Logging Improvement**: Replaced the exception raise with a warning log when an owner is already purged, improving observability during shutdown sequences.
* **Test Coverage**: Updated existing tests to verify idempotent behavior and added a new test case to ensure stop_process() succeeds even after the cache has been purged.
<details>
<summary><b>New Features</b></summary>
🧠You can now enable **Memory** (public preview) to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
</details>
<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>
The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
<b>Invoking Gemini</b>
You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help | `/gemini help` | Displays a list of available commands.
<b>Customization</b>
To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
<b>Limitations & Feedback</b>
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
</details>
[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org