Skip to content

Commit 8db26fd

Browse files
committed
assert that CancelHandle is unwind-safe
1 parent ef7ab4f commit 8db26fd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/coroutine/cancel.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::platform::sync::non_poison::Mutex;
22
use crate::{Py, PyAny};
33
use alloc::sync::Arc;
44
use core::future::poll_fn;
5+
use core::panic::AssertUnwindSafe;
56
use core::task::{Context, Poll, Waker};
67

78
#[derive(Debug, Default)]
@@ -14,7 +15,7 @@ struct Inner {
1415
///
1516
/// Only the last exception thrown can be retrieved.
1617
#[derive(Debug, Default)]
17-
pub struct CancelHandle(Arc<Mutex<Inner>>);
18+
pub struct CancelHandle(Arc<AssertUnwindSafe<Mutex<Inner>>>);
1819

1920
impl CancelHandle {
2021
/// Create a new `CoroutineCancel`.
@@ -54,7 +55,7 @@ impl CancelHandle {
5455
}
5556

5657
#[doc(hidden)]
57-
pub struct ThrowCallback(Arc<Mutex<Inner>>);
58+
pub struct ThrowCallback(Arc<AssertUnwindSafe<Mutex<Inner>>>);
5859

5960
impl ThrowCallback {
6061
pub(super) fn throw(&self, exc: Py<PyAny>) {

0 commit comments

Comments
 (0)