Skip to content

Commit 4e7f441

Browse files
committed
simplify `GenericSender::send
1 parent 4b80255 commit 4e7f441

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/generic.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,26 +1473,19 @@ where
14731473
Err(e) => {
14741474
if e.is_full() {
14751475
let mut tx = self.tx.clone();
1476-
Python::attach(move |py| {
1477-
Ok(
1478-
future_into_py_with_locals::<R, _, Py<PyAny>>(
1479-
py,
1480-
locals,
1481-
async move {
1482-
if tx.flush().await.is_err() {
1483-
// receiving side disconnected
1484-
return Python::attach(|py| false.into_py_any(py));
1485-
}
1486-
if tx.send(item).await.is_err() {
1487-
// receiving side disconnected
1488-
return Python::attach(|py| false.into_py_any(py));
1489-
}
1490-
Python::attach(|py| true.into_py_any(py))
1491-
},
1492-
)?
1493-
.into(),
1494-
)
1476+
1477+
future_into_py_with_locals::<R, _, bool>(py, locals, async move {
1478+
if tx.flush().await.is_err() {
1479+
// receiving side disconnected
1480+
return Ok(false);
1481+
}
1482+
if tx.send(item).await.is_err() {
1483+
// receiving side disconnected
1484+
return Ok(false);
1485+
}
1486+
Ok(true)
14951487
})
1488+
.map(Bound::unbind)
14961489
} else {
14971490
false.into_py_any(py)
14981491
}

0 commit comments

Comments
 (0)