mirror of
https://github.com/chatmail/core.git
synced 2026-04-24 17:06:28 +03:00
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.
This commit is contained in:
@@ -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"] }
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user