bugfix: await on size, assuming it can be an async function#1281
bugfix: await on size, assuming it can be an async function#1281mukhery wants to merge 2 commits intofsspec:masterfrom
Conversation
|
@martindurant what do you think? |
|
I think you are right in your argument. However, I have a feeling that f.size is never async actually, so it won't matter. open_async/AsyncStreamedFiles could use work! |
fsspec/s3fs#742 makes it async in order to call the async _info needed for _cp_file |
|
Funny, because S3 is the only one where for sure we should know the size before starting the download: the content-size header is always populated and, possibly outside compressive transcoding, will be correct. |
Perhaps I should change https://github.com/fsspec/filesystem_spec/blob/master/fsspec/generic.py#L277 to just remove the assumption that |
|
maybe_await should never be harmful and not add any overhead |
Checking
sizemay require a call to the async_infofunction. On line 277,_cp_filechecks iff1.sizeis async (callback.set_size(await maybe_await(f1.size))), but then later it simply referencesf1.sizewhich fails if this function is async. As such, this PR corrects the code to ensuref1.sizereferences are wrapped inawait maybe_await().