Skip to content

Fix 'Connection aborted, RemoteDisconnected' issue. - #579

Closed
FrogWan wants to merge 1 commit into
openai:mainfrom
FrogWan:users/kuwa/support_multi_process
Closed

FrogWan wants to merge 1 commit into
openai:mainfrom
FrogWan:users/kuwa/support_multi_process

Conversation

@FrogWan

@FrogWan FrogWan commented Aug 21, 2023 •

Copy link
Copy Markdown

Support multi process fork mode.
When multiprocessing start mode is "fork", subprocess will copy the _thread_context from main process, so subprocess will use main process _thread_context.session. if main process query open_ai again, it will have below error:
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')). so we need create a new _thread_context.session to prevent this issue.

@FrogWan FrogWan changed the title support multi process fork mode Fix 'Connection aborted, RemoteDisconnected' issue. Aug 22, 2023
@rattrayalex

Copy link
Copy Markdown
Contributor

Thanks for this!

We've since rewritten the library entirely, so this change is no longer relevant. I'm sorry we didn't get to it sooner.

@rattrayalex rattrayalex added the fixed in v1 Issues addressed by the v1 beta label Nov 10, 2023
safa0 pushed a commit to safa0/openai-agents-python that referenced this pull request Apr 27, 2025
Fix for openai#574 

@rm-openai I'm not sure how to add a test within the repo but I have
pasted a test script below that seems to work

```python
import asyncio
from openai.types.responses import ResponseTextDeltaEvent
from agents import Agent, Runner

async def main():
    agent = Agent(
        name="Joker",
        instructions="You are a helpful assistant.",
    )

    result = Runner.run_streamed(agent, input="Please tell me 5 jokes.")
    num_visible_event = 0
    async for event in result.stream_events():
        if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
            print(event.data.delta, end="", flush=True)
            num_visible_event += 1
            print(num_visible_event)
            if num_visible_event == 3:
                result.cancel()


if __name__ == "__main__":
    asyncio.run(main())
````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixed in v1 Issues addressed by the v1 beta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants