From 658d075e8d371ab94ef3567ff5ef35e7430f115a Mon Sep 17 00:00:00 2001 From: Sergey Boyko Date: Thu, 19 Jan 2023 12:41:11 +0100 Subject: [PATCH] Spawn `process_json_request` so the RPC requests can be processed asynchronously --- mm2src/mm2_main/src/rpc.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mm2src/mm2_main/src/rpc.rs b/mm2src/mm2_main/src/rpc.rs index 62e97a81b4..c94ec2714f 100644 --- a/mm2src/mm2_main/src/rpc.rs +++ b/mm2src/mm2_main/src/rpc.rs @@ -398,10 +398,16 @@ pub fn spawn_rpc(ctx_h: u32) { None => break, }; - let response = process_json_request(ctx, request_json, client).await; - if let Err(e) = response_tx.send(response) { - error!("Response is not processed: {:?}", e); - } + let spawner = ctx.spawner(); + let request_fut = async move { + let response = process_json_request(ctx, request_json, client).await; + if let Err(e) = response_tx.send(response) { + error!("Response is not processed: {:?}", e); + } + }; + // Spawn the `request_fut` so the requests can be processed asynchronously. + // Fixes: https://github.com/KomodoPlatform/atomicDEX-API/issues/1616 + spawner.spawn(request_fut); } }; ctx.spawner().spawn(fut);