Open
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 PyO3/pyo3#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.