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

better flush iopub with AsyncResults #2255

Merged
merged 2 commits into from Aug 6, 2012
Merged

better flush iopub with AsyncResults #2255

merged 2 commits into from Aug 6, 2012

Conversation

minrk
Copy link
Member

@minrk minrk commented Aug 4, 2012

requesting metadata (e.g. ar.data or ar.stdout) will result in flushing iopub if the outputs are incomplete, so separate wait(0) need not be called.

This also applies the workaround discussed in #2215

I'm not sure if it should close #2215, because the underlying cause there remains unknown.

requesting metadata (e.g. ar.data or ar.stdout) will result in flushing iopub if the outputs are incomplete, so separate wait(0) need not be called.

This also applies the workaround discussed in ipython#2215
@ellisonbg
Copy link
Member

I have tested this and it definitely fixes the behavior with accessing ar.data.


self._wait_for_outputs(10)
if timeout is not None and timeout < 0:
timeout = 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to hardcode 10 here? Just curious, I'm always a bit reluctant to have hardcoded constants in the middle of execution code...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 is putting an upper limit, when the user specified infinite wait. This is to avoid possible bugs where output never indicates itself as being done. Looking at it, the logic is actually slightly wrong, which I will fix now.

@fperez
Copy link
Member

fperez commented Aug 5, 2012

The code looks good, and since it fixes the problem we should go ahead, but I do have a quick question: do we have None, 0 and -1 all indicating 'infinite' timeout? If so, can we use only one of them?

@minrk
Copy link
Member Author

minrk commented Aug 5, 2012

The code looks good, and since it fixes the problem we should go ahead, but I do have a quick question: do we have None, 0 and -1 all indicating 'infinite' timeout? If so, can we use only one of them?

0 means no waiting at all (the opposite), but None and -1 both indicate infinite waits (None being more Pythonic, but -1 is inherited from the Pool.AsyncResult API, which we copied exactly).

I can unify on -1 for infinite wait, but I think we would have to cast None to -1 anyway, since it makes way more sense for timeout=None to mean 'no timeout'. We cannot unify on None (the more logical choice) if we want to preserve compatibility with pool.AsyncResult.

@minrk
Copy link
Member Author

minrk commented Aug 5, 2012

I should clarify: after this PR, the timeout=-1 means infinite wait in all cases. But we do allow the more logical timeout=None, which we cast to -1. So no changes are actually needed.

@fperez
Copy link
Member

fperez commented Aug 5, 2012

OK, thanks for the clarification. I had misunderstood the meaning of 0, and I think your reasoning for allowing None (but keeping compatibility with multiprocessing) is sound.

@fperez
Copy link
Member

fperez commented Aug 6, 2012

OK, I'm leaving #2215 open until we can further clarify if this fully closes it, but merging because it does address the problem of ar.data access, which we really need quickly. Thanks a ton, excellent job!

fperez added a commit that referenced this pull request Aug 6, 2012
better flush iopub with AsyncResults; requesting metadata (e.g. ar.data or ar.stdout) will result in flushing iopub if the outputs are incomplete, so separate wait(0) need not be called.
@fperez fperez merged commit 99eddce into ipython:master Aug 6, 2012
@minrk minrk deleted the arwait branch March 31, 2014 23:36
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
better flush iopub with AsyncResults; requesting metadata (e.g. ar.data or ar.stdout) will result in flushing iopub if the outputs are incomplete, so separate wait(0) need not be called.
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.

AsyncResult.wait(0) can hang waiting for the client to get results?
3 participants