openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

timeout not being respected by client.beta.threads.runs.create_and_poll (or .OpenAI)

Open Dev63 opened this issue 1 year ago • 2 comments

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • [X] This is an issue with the Python library

Describe the bug

Calling client.beta.threads.runs.create_and_poll(..., timeout=2.0) will wait as long as it takes before returning (6s, 5 minutes).

To Reproduce

Call client.beta.threads.runs.create_and_poll(..., timeout=2.0) and observe that it does not timeout.

Code snippets

No response

OS

Windows

Python version

Python 3.9

Library version

openai 1.51.2

Dev63 avatar Nov 07 '24 02:11 Dev63

Hi there! I noticed your issue and thought I’d share this related discussion that might offer some insights:

prdai avatar Jan 18 '25 04:01 prdai

Thank you for trying to help. That's actually a thread I started as well.

My expectations of a timeout parameter in a create_and_poll function would be that it would terminate the function if the specified amount of time passed with no resolution. Unfortunately, there’s no documentation of that parameter that I can find.

The other poster explains that the timeout parameter actually has to do with some internal networking stuff, and won't actually timeout the request. I'm not 100% sure he is correct, but if so, it's a weird thing to include, and misleading.

I do see that the underlying OpenAI API takes an expires_at parameter, which the Python library might have been able to use for real elegance, going a step beyond, but that parameter isn’t really documented either.

On Fri, Jan 17, 2025 at 11:25 PM Ranuga @.***> wrote:

Hi there! I noticed your issue and thought I’d share this related discussion that might offer some insights:

— Reply to this email directly, view it on GitHub https://github.com/openai/openai-python/issues/1855#issuecomment-2599520025, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHIPPEXKRITIZ52IPBKJP32LHJUVAVCNFSM6AAAAABRKGDW42VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJZGUZDAMBSGU . You are receiving this because you authored the thread.Message ID: @.***>

Dev63 avatar Jan 19 '25 21:01 Dev63