stac-utils/stac-asset

Document how to allow blocking requests when asyncio is running

gadomski opened this issue · 2 comments

Some environments, e.g. notebooks, spin up an asyncio runtime for you. Right now, this leads to breakages if you try to use stac_asset.blocking.* functions, since we use asyncio.run. We should update the blocking functions to use an existing runtime if possible, and only fall back to asyncio.run if need be.

Fixing this feels out-of-scope, so we should just document the usage of nest_asyncio.

AdeelH commented

I ran into this the other day too. Looks like simply calling nest_asyncio.apply() is sufficient (example).

I'd be happy to make a PR for this. Is adding a note in the README good enough?

Yeah, for now a README note would be great, thanks so much! For reference, this is how I ended up using it, similar to yours: https://github.com/stac-utils/stac-task/pull/42/files#diff-0ed2cf4aaeba2d2a23f6230accc39f7aedcf80e0feea2a89639c7633282f293aR148-R156.