Skip to content

Commit 413e93d

Browse files
committed
Move some with_gil calls outside of tokio event loop
1 parent 5ce66d1 commit 413e93d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/generic.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,11 @@ where
596596
let future_tx1: Py<PyAny> = py_fut.clone().into();
597597
let future_tx2 = future_tx1.clone_ref(py);
598598

599-
R::spawn(async move {
600-
let locals2 = Python::attach(|py| locals.clone_ref(py));
599+
let (locals2, locals3) = Python::attach(|py| (locals.clone_ref(py), locals.clone_ref(py)));
601600

601+
R::spawn(async move {
602602
if let Err(e) = R::spawn(async move {
603-
let result = R::scope(
604-
Python::attach(|py| locals2.clone_ref(py)),
605-
Cancellable::new_with_cancel_rx(fut, cancel_rx),
606-
)
607-
.await;
603+
let result = R::scope(locals3, Cancellable::new_with_cancel_rx(fut, cancel_rx)).await;
608604

609605
Python::attach(move |py| {
610606
if cancelled(future_tx1.bind(py))

0 commit comments

Comments
 (0)