Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is async file reading supported? #11

Open
NicolasHug opened this issue Feb 8, 2022 · 3 comments
Open

Is async file reading supported? #11

NicolasHug opened this issue Feb 8, 2022 · 3 comments

Comments

@NicolasHug
Copy link

The docs of PathManager.opena() suggest that async reading is supported:

Usage (read):
async def my_function():
return await path_manager.opena(uri, "r").read()

But running the suggested code leads to the following error:

# Restrict mode until `NonBlockingIO` has async read feature.
valid_modes = {"w", "a", "b"}
if not all(m in valid_modes for m in mode):
raise ValueError(f"`opena` mode must be write or append for path {path}")

Are there plans to support async file reading? Thanks!

@sujitoc
Copy link
Contributor

sujitoc commented Feb 8, 2022

Async reads are currently not supported for the generic PathHandler. However, one path handler (for internal Meta use) does support it.

@NicolasHug
Copy link
Author

Thanks for your reply @sujitoc . Would you know if there are plans to support async reading for regular on-disk files?

Darktex pushed a commit to Darktex/iopath that referenced this issue Dec 12, 2022
…s. (facebookresearch#11)

Summary: Pull Request resolved: fairinternal/iopath#11

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

buck test mode/opt  //fair_infra/data/iopath/tests:iopath_test

Reviewed By: kkondaka

Differential Revision: D32680188

Pulled By: sujitoc

fbshipit-source-id: f0fca7de34a15ab0217a01306fe87f46126c23d6
@rjy7wb
Copy link

rjy7wb commented Apr 8, 2023

this code already looks a lot like https://github.com/python/cpython/blob/3.11/Lib/asyncio/streams.py

more specifically the StreamReader, and StreamWriter classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants