Description
PyEngine::new() in python/src/engine.rs:116 creates its own Runtime::new() and calls rt.block_on() to build the engine. This creates a separate tokio runtime from the one used by pyo3_async_runtimes for async method calls.
This can cause issues when:
- The user is already running an async event loop (e.g. Jupyter, FastAPI)
- Multiple Engine instances are created — each spawns its own runtime
- The background graph rebuild task runs on a different runtime than the engine's async methods
Relevant Code
python/src/engine.rs:116-143 — PyEngine::new() with Runtime::new().block_on()
Suggested Fix
Use pyo3_async_runtimes::tokio::get_runtime() to share a single tokio runtime, or lazily initialize the engine on first async method call instead of in __init__.
Description
PyEngine::new()inpython/src/engine.rs:116creates its ownRuntime::new()and callsrt.block_on()to build the engine. This creates a separate tokio runtime from the one used bypyo3_async_runtimesfor async method calls.This can cause issues when:
Relevant Code
python/src/engine.rs:116-143—PyEngine::new()withRuntime::new().block_on()Suggested Fix
Use
pyo3_async_runtimes::tokio::get_runtime()to share a single tokio runtime, or lazily initialize the engine on first async method call instead of in__init__.