From 1cb6ab5f02b8cbf32a549688ea37488536a086d0 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:42:02 -0400 Subject: [PATCH] Update _cache.py --- eth_portfolio/_cache.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/eth_portfolio/_cache.py b/eth_portfolio/_cache.py index 5560e724..e28cd63b 100644 --- a/eth_portfolio/_cache.py +++ b/eth_portfolio/_cache.py @@ -53,16 +53,13 @@ async def cache_deco_worker_coro() -> NoReturn: @functools.wraps(fn) async def disk_cache_wrap(*args: P.args, **kwargs: P.kwargs) -> T: cache_path = get_cache_file_path(args, kwargs) + fut = get_event_loop().create_future() + queue.put_nowait((fut, cache_path, args, kwargs)) + if workers is None: + workers = tuple(create_task(cache_deco_worker_coro()) for _ in range(1000)) try: - fut = get_event_loop().create_future() - queue.put_nowait((fut, cache_path, args, kwargs)) - if workers is None: - workers = tuple(create_task(cache_deco_worker_coro()) for _ in range(1000)) - try: - return await fut - except EOFError: - pass - except FileNotFoundError: + return await fut + except (FileNotFoundError, EOFError): pass async_result: T = await fn(*args, **kwargs)