Skip to main content

call_python_threadsafe

Function call_python_threadsafe 

Source
pub fn call_python_threadsafe(
    py: Python<'_>,
    call_soon: &Py<PyAny>,
    callback: &Py<PyAny>,
    py_obj: Py<PyAny>,
)
Expand description

Schedules a Python callback on the event loop thread via call_soon_threadsafe.

This must be used instead of call_python when invoking Python callbacks from Tokio worker threads, since Python callbacks that enter the kernel (e.g. via MessageBus.send) must run on the asyncio event loop thread.