Skip to content

Commit

Permalink
fix async shutdown handler
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Sep 28, 2024
1 parent b3fb48a commit d7f901b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/executors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand Down

0 comments on commit d7f901b

Please sign in to comment.