Skip to content

Conversation

@dhermes
Copy link
Contributor

@dhermes dhermes commented Oct 24, 2016

This is in advance of supporting GAX page iterators within our Iterator class.

Iterator.reset() isn't a feature that a typical Python user expects to exist, and restarting an iterator can be as easy as:

>>> my_iter = client.list_foo(*args, **kwargs)
>>> consume_it(my_iter)
>>> restarted_iter = client.list_foo(*args, **kwargs)

This is in advance of supporting GAX page iterators
within our Iterator class.

Iterator.reset() isn't a feature that a typical Python
user expects to exist, and restarting an iterator can
be as easy as:

>>> my_iter = client.list_foo(*args, **kwargs)
>>> consume_it(my_iter)
>>> restarted_iter = client.list_foo(*args, **kwargs)
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 24, 2016
@daspecster
Copy link
Contributor

>>> my_iter = client.list_foo(*args, **kwargs)
>>> consume_it(my_iter)
>>> restarted_iter = client.list_foo(*args, **kwargs)  # API call.
>>> my_iter.reset()  # No API call.

I don't know if that matters? Supporting GAX page iterators is a bigger benefit over making an extra API call I would think.

@dhermes
Copy link
Contributor Author

dhermes commented Oct 24, 2016

@daspecster It's not about API calls, it's about not being able to re-set to the initial state for a GAX iterator. And calling list_foo() doesn't make any API calls until the user starts to consume the iterator.

@dhermes dhermes merged commit dca5600 into googleapis:master Oct 24, 2016
@dhermes dhermes deleted the remove-iterator-restart branch October 24, 2016 16:34
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: core cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants