question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] async not working?

See original GitHub issue

What happened:

As a warmup, we’ve been trying to do async fs.exists() for abfs and are unsure if async is not supported, version issue, bug on our end, etc

What you expected to happen:

Async existence check returns True / False, not an exception

Minimal Complete Verifiable Example:

fs = fsspec.filesystem('abfs', asynchronous=True, account_name='...', account_key='...')

#session = await fs.set_session()  # exn: no method defined

await fs.exists('abfs://container/folder/file')  # exn: Loop is not running

Anything else we need to know?:

Environment:

  • Dask version: 2021.04.0
  • fsspec: 2021.06.01
  • adlfs: v0.7.3
  • Python version: 3.7
  • Operating System: Ubuntu
  • Install method (conda, pip, source): conda (rapids 0.19) + updates

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hayesgbcommented, Jul 17, 2021

At this point in time, the asynchronous parameter introduced by fsspec will not enable adlfs to be called asynchronously (i.e. using the await keyword). Instead, operations within the package are executed asynchronously, such that traditional sync calls (i.e. fs.exists()) triggers async execution under the hood.

Adding direct async calls under the hood is on the roadmap.

0reactions
martindurantcommented, Jul 27, 2021

@lmeyerov , have you tried (note the underscore)

await fs._exists('abfs://container/folder/file')

?

This is how it is spelled in the other async implementations. In async mode, you must not call any of the methods that call sync().

Sounds like we can do this async off-main-thread, but cannot interleave filecache writes, so should enforce a global fsspec writelock on those tasks

Simpler than implementing and exposing a lock, would be to make the filecache threadsafe. It’s the updating of the metadata file that can cause (occasional) races, if someone wants to have a go. (It is also possible that two threads download the same file simultaneously, which is not critical, but would be wasteful). The same is true for blockcache, although it should be checked whether the same file can be opened from multiple threads.

I’m assuming in async operations that the loop does not need to be passed in explicitly, but I’d like to get @martindurant 's input on this.

Correct, if you have asynchronous=True, you should be using await and coroutines only, and the loop is the current running loop. By default, fsspec has its own loop in a thread. Tthe parameter is there for two cases:

  • the user wants another thread/loop to run fsspec for sync calls
  • you will use async mode, but the instance was created outside of the loop (not recommended!)

Yes, we have talked about the possibility to treat IO tasks differently in dask, but no concrete work yet. In some cases, IO can use significant CPU (e.g., HTTP automatic compression/encryption); what really sets IO apart is high latency. It may be reasonable for a dask thread to secede during an fsspec blocking call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] async not working? · Issue #253 · fsspec/adlfs - GitHub
As a warmup, we've been trying to do async fs.exists() for abfs and are unsure if async is not supported, version issue, bug...
Read more >
Async inside async function bug - node.js - Stack Overflow
I am trying to call simple view and within that I am making another query with the data from the view. My problem...
Read more >
Error handling with async/await and promises, n² ... - CatchJS
Async await error handling has a bunch of edge cases. Here's the full run down of how to ... Using the .catch(() =>...
Read more >
Async/await - The Modern JavaScript Tutorial
So, async ensures that the function returns a promise, and wraps non-promises in it. Simple enough, right? But not only that. There's another ......
Read more >
An Async Example - Jest
error : `User with ${userID} not found.`, }), ); }); }. Now let's write a test for our async functionality. __tests__/user-test.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found