You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python SDK: a fork in a signal handler during a prompt fetch makes the child call wait for the fetch timeout #107
The fix of #98 (#105) resets pending prompt fetches in a forked child. It does not cover one case: a fork in a signal handler while a get_prompt call waits for a fetch.
The call waits on the event of the fetch in _prompts.py. After the fork, the child call continues to wait on the copied event, but no thread in the child sets that event. Thus the child call waits until the fetch timeout (up to 10 s) and then raises a timeout error, although the server answers at once.
Repro: with _FETCH_TIMEOUT_S = 2 and a server delay of 1 s, a call waits for a fetch, and a SIGALRM handler calls os.fork() 0.3 s later. The parent gets the prompt in 1.00 s. The child raises PromptError('Fetching the prompt took more than 2 s') after 2.00 s. This occurred on Python 3.10, 3.12, and 3.13 on Linux.
What to do:
After the wait on a pending event, compare the process ID with the ID of the fetch.
If the process ID changed, start a new fetch in the child.
Add a real-fork test with a signal handler, as in the repro.
Activity
fix(sdk-python): recover prompt fetches and the cache lock in forked …