fix(streaming): never close OpenAI shared client from watchdog#71105
Open
xrwang8 wants to merge 1 commit into
Open
fix(streaming): never close OpenAI shared client from watchdog#71105xrwang8 wants to merge 1 commit into
xrwang8 wants to merge 1 commit into
Conversation
…esearch#70773) The OpenAI-wire streaming cleanup (stale_stream, stream_retry, stream_mid_tool_retry) called _replace_primary_openai_client() to swap self.client and close the old shared pool. The stale site ran from the poll (stranger) thread, and the retry sites ran from the request worker — either way, closing the shared pool while sibling workers held sockets from that pool left FDs live for recycling when httpx called os.close(). NousResearch#70773 is the production forensic showing that FD-recycle vector corrupted kanban.db. Since NousResearch#67142, OpenAI-wire streams run on a per-request client: the stale watchdog aborts the request-local client's socket (poll thread) and the worker closes its own client (worker thread) — the shared self.client is never closed from inside a request. This commit removes the three _replace_primary_openai_client() calls and adds regression tests asserting that the shared client survives cleanup, while the request-local abort/close still fires. Fixes NousResearch#70773. Extends NousResearch#67142. Signed-off-by: xrwang8 <xrwang8@gmail.com>
Collaborator
Duplicate of #70993: the merged current-head repair already removes these three shared-client replacement calls and adds the broader safe-retirement coverage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #70773 - OpenAI-wire watchdog closes shared client from non-owner thread
Changes
Testing
Related
Fixes #70773