From 15414aa378e24cd65f4751e6c83966c68c6ebaf2 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 6 Jan 2022 20:24:23 +0000 Subject: [PATCH] run_session(): minor code cleanup --- mmgen/util.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mmgen/util.py b/mmgen/util.py index 40f76afc..efda7597 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -950,18 +950,17 @@ def write_mode(orig_func): return f def run_session(callback,backend=None): - backend = backend or opt.rpc_backend - import asyncio + async def do(): - if backend == 'aiohttp': + if (backend or opt.rpc_backend) == 'aiohttp': import aiohttp async with aiohttp.ClientSession( headers = { 'Content-Type': 'application/json' }, connector = aiohttp.TCPConnector(limit_per_host=g.aiohttp_rpc_queue_len), ) as g.session: - ret = await callback - return ret + return await callback else: return await callback + import asyncio return asyncio.run(do())