Skip to content

Split sync and async return iterators for Get and List #19

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kylebarron
Copy link
Member

In obstore it's very convenient to have a single method that returns both an async and a sync iterator. You can call list() and iterate over either with for or async for.

But I imagine that some obspec implementations will be either only sync or only async. In this case, we don't want to require that the returned value can always be iterated over in both manners.

So it's probably good to have some separation in the protocol. Here, this PR suggests a separation between Get and GetAsync where Get returns a synchronous iterator and GetAsync returns an async iterator. I think this should be compatible with obstore because obstore's iterators are a superset.

It would be nice to have a single list named method still, but it doesn't look like Python can intersect the return objects. So you can't have a List and ListAsync protocol that each define def list(), even if you could imagine having an intersection of their return iterators.

In practice, this means that obstore would need to get an essentially duplicative list_async method. Even though that function would return the same thing as obstore.list

Closes #10

cc @sharkinsspatial @maxrjones @TomNicholas

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

Successfully merging this pull request may close these issues.

Distinction between sync and async iterator return types?
1 participant