Skip to content

Removing Iterator.reset(). - #2592

Merged
dhermes merged 1 commit into
googleapis:masterfrom
dhermes:remove-iterator-restart
Oct 24, 2016
Merged

Removing Iterator.reset().#2592
dhermes merged 1 commit into
googleapis:masterfrom
dhermes:remove-iterator-restart

Conversation

@dhermes

Copy link
Copy Markdown
Contributor

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)
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 24, 2016
@daspecster

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

@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:masterOct 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: corecla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@dhermes@daspecster@theacodes@tseaver@googlebot