Skip to content

Commit

Permalink
Catch PyStopAsyncIteration in callback_impl_loop_step macro
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Jul 9, 2024
1 parent 24db55e commit e0c3c4a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ macro_rules! callback_impl_loop_step {
($pyself.into_py($py).getattr($py, pyo3::intern!($py, "_loop_wake"))?,),
Some(&kwctx),
)?;
Ok(())
}
false => {
let event_loop = $pyself.context.event_loop($py);
Expand All @@ -366,18 +365,20 @@ macro_rules! callback_impl_loop_step {
($pyself.into_py($py).getattr($py, pyo3::intern!($py, "_loop_step"))?,),
Some(&kwctx),
)?;
Ok(())
}
}
Ok(())
}
Err(err) => {
Err(err)
if (err.is_instance_of::<pyo3::exceptions::PyStopIteration>($py)
|| err.is_instance_of::<pyo3::exceptions::asyncio::CancelledError>($py))
{
$pyself.done();
} else {
$pyself.err(&err);
}
|| err.is_instance_of::<pyo3::exceptions::PyStopAsyncIteration>($py)
|| err.is_instance_of::<pyo3::exceptions::asyncio::CancelledError>($py)) =>
{
$pyself.done();
Ok(())
}
Err(err) => {
$pyself.err(&err);
Ok(())
}
}
Expand Down

0 comments on commit e0c3c4a

Please sign in to comment.