Compare commits

...

1 Commits

Author SHA1 Message Date
link2xt
eaf461707b fix(deltachat-rpc-server): always run with at least two threads
We already run all async tests with
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
as we had problems in the past when running them with one thread.

This is a similar change for deltachat-rpc-server
that hopefully prevents timeouts of deltachat-rpc-client tests
on CI.
2023-10-28 00:08:40 +00:00
2 changed files with 13 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ anyhow = "1"
env_logger = { version = "0.10.0" }
futures-lite = "2.0.0"
log = "0.4"
num_cpus = "1"
serde_json = "1.0.105"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.33.0", features = ["io-std"] }

View File

@@ -20,9 +20,18 @@ use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken;
use yerpc::{RpcClient, RpcSession};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let r = main_impl().await;
fn main() {
// Build multithreaded runtime with at least two threads.
// This ensures that on systems with one CPU
// such as CI runners there are at least two threads
// and it is more difficult to deadlock.
let r = tokio::runtime::Builder::new_multi_thread()
.worker_threads(std::cmp::max(2, num_cpus::get()))
.enable_all()
.build()
.unwrap()
.block_on(main_impl());
// From tokio documentation:
// "For technical reasons, stdin is implemented by using an ordinary blocking read on a separate
// thread, and it is impossible to cancel that read. This can make shutdown of the runtime hang