Skip to content
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

IPython.parallel.Client behavior as iterator #5519

Closed
skiguy0123 opened this issue Apr 4, 2014 · 2 comments · Fixed by #5522
Closed

IPython.parallel.Client behavior as iterator #5519

skiguy0123 opened this issue Apr 4, 2014 · 2 comments · Fixed by #5522
Milestone

Comments

@skiguy0123
Copy link

Iterating over a Client only works if the engine ids start at 0, resulting in inconsistent behavior:

In [1]: from IPython.parallel import Client

In [2]: c = Client()

In [3]: print c[:]
<DirectView [0, 1, 2, 3]>

In [4]: for ct in c:
   ...:     print ct
   ...:     
<DirectView 0>
<DirectView 1>
<DirectView 2>
<DirectView 3>

In [5]: c = Client()

In [6]: print c[:]
<DirectView [4, 5, 6, 7]>

In [7]: for ct in c:
   ...:     print ct
   ...:     

In [8]: 

Whether Client should be an iterator or not, I think it should at least be consistent.

@minrk
Copy link
Member

minrk commented Apr 4, 2014

I didn't intend for Client to be iterable (it's a side effect of defining __getitem__). Might as well make it consistent, since the behavior is already there.

@minrk minrk added this to the 2.1 milestone Apr 4, 2014
@skiguy0123
Copy link
Author

Thanks!

minrk added a commit that referenced this issue Apr 9, 2014
I didn't intend for Client to be iterable, but defining `__getitem__` makes it iterable as long as engine IDs are continuous (not always the case).

This explicitly defines `__iter__` so it behaves consistently.

closes #5519
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 a pull request may close this issue.

2 participants