From 0d57a799b5f2322900d0b07c42ea0bc5fcad2437 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 27 Jan 2023 20:53:43 +0200 Subject: [PATCH] Port RPC "registry.call_client" to async --- platformio/home/rpc/handlers/registry.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/home/rpc/handlers/registry.py b/platformio/home/rpc/handlers/registry.py index fa6f702c..34d0974b 100644 --- a/platformio/home/rpc/handlers/registry.py +++ b/platformio/home/rpc/handlers/registry.py @@ -13,16 +13,17 @@ # limitations under the License. from ajsonrpc.core import JSONRPC20DispatchException +from starlette.concurrency import run_in_threadpool from platformio.registry.client import RegistryClient class RegistryRPC: @staticmethod - def call_client(method, *args, **kwargs): + async def call_client(method, *args, **kwargs): try: client = RegistryClient() - return getattr(client, method)(*args, **kwargs) + return await run_in_threadpool(getattr(client, method), *args, **kwargs) except Exception as exc: # pylint: disable=bare-except raise JSONRPC20DispatchException( code=5000, message="Registry Call Error", data=str(exc)