Skip to content

fix: don't stop thread managers owned by another process - #2728

Closed
gofreight-jackyeh wants to merge 1 commit into
elastic:mainfrom
gofreight-jackyeh:fix/skip-stopping-threads-owned-by-another-process
Closed

gofreight-jackyeh wants to merge 1 commit into
elastic:mainfrom
gofreight-jackyeh:fix/skip-stopping-threads-owned-by-another-process

Conversation

@gofreight-jackyeh

@gofreight-jackyeh gofreight-jackyeh commented Aug 25, 2026 •

Copy link
Copy Markdown

Withdrawn — opened in error, without authorization from my side. Apologies for the noise.

`ThreadManager.is_started()` compares the pid that started the manager's
threads with the current pid, but nothing ever called it. `Client.close()`
stopped every thread manager unconditionally, so a pre-forked worker would
cancel the timers its parent started.

`Transport.close()` already guards on `self._thread.pid != os.getpid()`, so
transport was safe; `MetricsRegistry` (guarded on `is_alive()`) and
`VersionedConfig` (guarded on the attribute merely being set) were not.

Servers that fork workers without running CPython's after-fork cleanup —
uWSGI in its default prefork mode, i.e. without `--py-call-uwsgi-fork-hooks`
— leave the child's `threading` module believing the parent's threads are
still alive, so `is_alive()` stays True in the child and the guard does not
help. Cancelling those timers calls `Event.set()` on objects belonging to
threads that do not exist in this process. On Python 3.13+, where locks are
built on `PyMutex`, that segfaults the worker in `_PyParkingLot_Unpark`.

Guard the loop in `Client.close()` with the check the base class already
provides, so it covers every thread manager instead of each one having to
remember.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gofreight-jackyeh
gofreight-jackyeh requested a review from a team as a code owner August 25, 2026 06:03
@cla-checker-service

Copy link
Copy Markdown

❌ Author of the following commits did not sign a Contributor Agreement:
4b48a14

Please, read and sign the above mentioned agreement if you want to contribute to this project

@github-actions

Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@github-actions github-actions Bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Aug 25, 2026
@gofreight-jackyeh
gofreight-jackyeh deleted the fix/skip-stopping-threads-owned-by-another-process branch August 25, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-python community Issues opened by the community triage Issues awaiting triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant