Description
Filing this ticket here as a precursor to supporting async is pystac-client:
Currently:
- pystac only supports sync reads (from file or URL) and writes (to file). The desire to to also support an async API, so that users who wish to use this in an async context don't have to block or wrap calls in an executor.
- file i/o is done via the
open
built-in - network i/o is done via urllib
Ideally, we would have as little duplicated code as possible, though the actual code for doing the i/o is pretty small (low tens of lines), and would easy to maintain if not shared, and the added complexity of contorting the code to work with or without the async keyword is probably not worth it.
File I/O
Continue to use built-io i/o for sync, and aiofiles library for async.
Network I/O
One approach to this is to use the api-compatible pairs of libraries for sync and async, e.g., requests / niquests (sync) and httpx (async) or urllib (sync, and currently used) and urllib3.future (async) (maybe? I don't know how similar urllib3 and urllib are?).
Or, just have a bit of duplicated-ish code and use urllib for sync (no external dependency) and httpx for async.