From 8b2bf0cb8879da24f7d4aa615f296a3d646fde04 Mon Sep 17 00:00:00 2001 From: Ryan Mukherjee Date: Mon, 29 May 2023 12:54:04 -0400 Subject: [PATCH 1/2] await on size, assuming it can be an async function --- fsspec/generic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fsspec/generic.py b/fsspec/generic.py index 18e27405a..f95de1d4c 100644 --- a/fsspec/generic.py +++ b/fsspec/generic.py @@ -280,9 +280,12 @@ async def _cp_file( if hasattr(fs2, "open_async") else fs2.open(url2, "wb", **kw) ) - while f1.size is None or f2.tell() < f1.size: + while ( + await maybe_await(f1.size) is None + or f2.tell() < await maybe_await(f1.size) + ): data = await maybe_await(f1.read(blocksize)) - if f1.size is None and not data: + if await maybe_await(f1.size) is None and not data: break await maybe_await(f2.write(data)) callback.absolute_update(f2.tell()) From 69dd8af13e264a930eedf99440473c0c6b633a5d Mon Sep 17 00:00:00 2001 From: Ryan Mukherjee Date: Thu, 1 Jun 2023 09:19:32 -0400 Subject: [PATCH 2/2] black --- fsspec/generic.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fsspec/generic.py b/fsspec/generic.py index f95de1d4c..869047746 100644 --- a/fsspec/generic.py +++ b/fsspec/generic.py @@ -280,9 +280,8 @@ async def _cp_file( if hasattr(fs2, "open_async") else fs2.open(url2, "wb", **kw) ) - while ( - await maybe_await(f1.size) is None - or f2.tell() < await maybe_await(f1.size) + while await maybe_await(f1.size) is None or f2.tell() < await maybe_await( + f1.size ): data = await maybe_await(f1.read(blocksize)) if await maybe_await(f1.size) is None and not data: