temporalio / temporalio/sdk-python
[Bug] Investigate PyGILState_Release issue for client
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 241
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 55
Description
Describe the bug
On short-lived client-only process after execute_workflow client call completes, one user reported getting:
Fatal Python error: PyGILState_Release: thread state 0x***************** must be current when releasing
Python runtime state: finalizing (tstate=0x*****************)
Thread 0x****************** (most recent call first):
<no Python frame>
Maybe this is caused by process death while waiting on client call complete? Try to replicate.
There is some discussion at https://github.com/PyO3/pyo3/issues/1274 that predates pyo3-asyncio. Maybe I am not implementing our custom Tokio pyo3 asyncio extension properly?
It looks like we shouldn't be calling Python::with_gil in callbacks (i.e. not in Python-owned thread) for any reason, so we need to work around that. But https://pyo3.rs/main/ecosystem/async-await.html#awaiting-a-rust-future-in-python shows it used in a callback.
First thing is a replication, then we can see whether an pyo3-asyncio upgrade can help.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by reproducing the crash after the client-side execute_workflow call completes in a short-lived process. Read the custom Tokio pyo3-asyncio extension and the linked PyO3 discussion, then check whether a pyo3-asyncio upgrade changes the behavior. Done means the failure is reproduced or ruled out and the cause or a validated direction is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100