Skip to content

Commit

Permalink
use a small timeout?
Browse files Browse the repository at this point in the history
  • Loading branch information
brayniac committed Jul 27, 2023
1 parent 9698786 commit a418911
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/clients/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::workload::ClientRequest;
use crate::workload::ClientWorkItem as WorkItem;
use crate::*;
use ::momento::MomentoError;
use crossbeam::channel::{Receiver, TryRecvError};
use crossbeam::channel::{Receiver, RecvTimeoutError};
use std::io::{Error, ErrorKind, Result};
use tokio::io::*;
use tokio::runtime::Runtime;
Expand Down
6 changes: 3 additions & 3 deletions src/clients/redis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ async fn task(work_receiver: Receiver<WorkItem>, endpoint: String, config: Confi
}

let mut con = connection.take().unwrap();
let work_item = match work_receiver.try_recv() {
let work_item = match work_receiver.recv_timeout(Duration::from_micros(10)) {
Ok(item) => item,
Err(TryRecvError::Empty) => {
Err(RecvTimeoutError::Timeout) => {
tokio::task::block_in_place(|| work_receiver.recv())
.map_err(|_| Error::new(ErrorKind::Other, "channel closed"))?
}
Err(_) => {
Err(RecvTimeoutError::Disconnected) => {
return Err(Error::new(ErrorKind::Other, "channel closed"));
}
};
Expand Down

0 comments on commit a418911

Please sign in to comment.