src/backup/catalog.rs - SenderWriter: use tokio::task::block_in_place

Make sure we do not block the executor.
This commit is contained in:
Dietmar Maurer 2020-01-16 14:24:15 +01:00
parent 94609e2380
commit d2dd827877
1 changed files with 6 additions and 4 deletions

View File

@ -384,10 +384,12 @@ impl SenderWriter {
impl Write for SenderWriter { impl Write for SenderWriter {
fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> { fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
futures::executor::block_on(async move { tokio::task::block_in_place(|| {
self.0.send(Ok(buf.to_vec())).await futures::executor::block_on(async move {
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err.to_string()))?; self.0.send(Ok(buf.to_vec())).await
Ok(buf.len()) .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err.to_string()))?;
Ok(buf.len())
})
}) })
} }