Thread 'tokio-runtime-worker' panicked at 'thread 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 24, kind: Other, message: "Too many open files" })

You're using thread::sleep to sleep in an async function. This is a very bad idea and will incredibly quickly exhaust all of the executor's threads. It only has four or eight depending on your cpu, so once you're running four or eight sleeps, you're out of threads. You need to use Tokio's delay_for, which gives control of the thread back to Tokio during the sleep. Consider reading this thread.

4 Likes