mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 03:43:22 +01:00
Merge pull request #106 from teloxide/use_tokio_task_unconstrained
Use `tokio::task::unconstrained` when using `.now_or_never()` to prevent some problems I guess
This commit is contained in:
commit
261be16b47
1 changed files with 2 additions and 2 deletions
|
@ -495,7 +495,7 @@ async fn worker(
|
||||||
|
|
||||||
fn answer_info(rx: &mut mpsc::Receiver<InfoMessage>, limits: &mut Limits) {
|
fn answer_info(rx: &mut mpsc::Receiver<InfoMessage>, limits: &mut Limits) {
|
||||||
// FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350
|
// FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350
|
||||||
while let Some(Some(req)) = rx.recv().now_or_never() {
|
while let Some(Some(req)) = tokio::task::unconstrained(rx.recv()).now_or_never() {
|
||||||
// Errors are ignored with .ok(). Error means that the response channel
|
// Errors are ignored with .ok(). Error means that the response channel
|
||||||
// is closed and the response isn't needed.
|
// is closed and the response isn't needed.
|
||||||
match req {
|
match req {
|
||||||
|
@ -519,7 +519,7 @@ async fn read_from_rx<T>(rx: &mut mpsc::Receiver<T>, queue: &mut Vec<T>, rx_is_c
|
||||||
// Don't grow queue bigger than the capacity to limit DOS posibility
|
// Don't grow queue bigger than the capacity to limit DOS posibility
|
||||||
while queue.len() < queue.capacity() {
|
while queue.len() < queue.capacity() {
|
||||||
// FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350
|
// FIXME(waffle): https://github.com/tokio-rs/tokio/issues/3350
|
||||||
match rx.recv().now_or_never() {
|
match tokio::task::unconstrained(rx.recv()).now_or_never() {
|
||||||
Some(Some(req)) => queue.push(req),
|
Some(Some(req)) => queue.push(req),
|
||||||
Some(None) => *rx_is_closed = true,
|
Some(None) => *rx_is_closed = true,
|
||||||
// There are no items in queue.
|
// There are no items in queue.
|
||||||
|
|
Loading…
Reference in a new issue