From d7f901b0459e20c75521d69925cb3e4a0f01d9ae Mon Sep 17 00:00:00 2001 From: VishnuSanal Date: Sat, 28 Sep 2024 12:50:17 +0530 Subject: [PATCH] fix async shutdown handler --- src/executors/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/executors/mod.rs b/src/executors/mod.rs index 34dd36ab8..db05a425d 100644 --- a/src/executors/mod.rs +++ b/src/executors/mod.rs @@ -108,12 +108,14 @@ pub async fn execute_event_handler( if function.is_async { debug!("Startup event handler async"); Python::with_gil(|py| { - pyo3_asyncio::into_future_with_locals( - task_locals, - function.handler.as_ref(py).call0()?, + pyo3_asyncio::tokio::run_until_complete( + task_locals.event_loop(py), + pyo3_asyncio::into_future_with_locals( + task_locals, + function.handler.as_ref(py).call0()?, + ).unwrap(), ) - })? - .await?; + })?; } else { debug!("Startup event handler"); Python::with_gil(|py| function.handler.call0(py))?;