Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Nov 18, 2024
1 parent 195804d commit 0c9e858
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ where
{
fn send(&mut self, py: Python, locals: TaskLocals, item: PyObject) -> PyResult<PyObject> {
match self.tx.try_send(item.clone_ref(py)) {
Ok(_) => true.into_pyobject(py),
Ok(_) => Ok(true.into_pyobject(py)?.as_ref().unbind()),
Err(e) => {
if e.is_full() {
let mut tx = self.tx.clone();
Expand All @@ -1491,19 +1491,23 @@ where
async move {
if tx.flush().await.is_err() {
// receiving side disconnected
return Python::with_gil(|py| Ok(false));
return Python::with_gil(|py| {
Ok(false.into_pyobject(py)?.as_ref().unbind())
});
}
if tx.send(item).await.is_err() {
// receiving side disconnected
return Python::with_gil(|py| Ok(false));
return Python::with_gil(|py| {
Ok(false.into_pyobject(py)?.as_ref().unbind())
});
}
Python::with_gil(|py| Ok(true))
Python::with_gil(|py| Ok(true.into_pyobject(py)?.as_ref().unbind()))
},
)?
.into())
})
} else {
Ok(false.into_py(py))
Ok(false.into_pyobject(py)?.as_ref().unbind())
}
}
}
Expand Down

0 comments on commit 0c9e858

Please sign in to comment.