Skip to content

Conversation

@minrk
Copy link
Member

@minrk minrk commented Dec 8, 2015

removes need to call sys.stdout.flush during blocking loops for backward-compatibility, a BackgroundSocket is passed around that transparently sends messages via the IOPub thread.

I had a hell of a time debugging weird hangs with multiprocessing, but they seem to be gone, now, thanks to a well-placed threading.Event.

closes jupyter/notebook#700
closes #77

@minrk minrk added this to the 4.3 milestone Dec 8, 2015
@minrk minrk force-pushed the io-thread branch 2 times, most recently from e056263 to 20221e9 Compare December 21, 2015 15:05
@minrk
Copy link
Member Author

minrk commented Dec 21, 2015

I think this should be ready to go, now. The one thing I'm not thrilled about is the workaround of the fork-safety check in Session.send, since that's in jupyter_client. It would be nice if there were a way to say "I'm fork-safe, trust me"

@minrk
Copy link
Member Author

minrk commented Jan 13, 2016

I made the fork-safe check optional in jupyter/jupyter_client#107, so we can clean that up later when we bump dependencies.

Since this has been ready to go for some time now, I'll merge before too long unless someone wants to do some review.

@takluyver
Copy link
Member

Sorry for leaving this unreviewed so long. I will try to have a careful look at it either this evening or tomorrow (just about to head home before the rain gets too hard).

Copy link
Member

Choose a reason for hiding this comment

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

When I'm overriding __getattr__ and __setattr__, I like to check for attempts at __special__ attribute access, and make them behave as normal; otherwise things can get quite confused.

Copy link
Member Author

Choose a reason for hiding this comment

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

__methods__ don't passthrough and Socket attr access is deprecated. I didn't find any actual use of it, so it may be overly cautious, though it may be that ipyparallel will rely on it for some transition.

@minrk
Copy link
Member Author

minrk commented Jan 14, 2016

Re: BackgroundSocket I didn't deprecated the socket API because I don't really have an idea for a better one. If nothing else, it's going to be an object with a send method that takes a message, so I'm not sure how different it's going to be from the socket API that we need to keep for backward compatibility.

Do you have any ideas on that point?

@takluyver
Copy link
Member

Fair enough. Is it worth deprecating the shortcut access to all of the socket methods besides send? What actually uses those?

@minrk
Copy link
Member Author

minrk commented Jan 15, 2016

Is it worth deprecating the shortcut access to all of the socket methods besides send?

I expect so. I'll take a stab at that, and see what might be using them, if anything.

@minrk minrk self-assigned this Jan 15, 2016
minrk added 6 commits January 19, 2016 13:59
removes need to call `sys.stdout.flush` during blocking loops
for backward-compatibility, a BackgroundSocket is passed around that transparently sends messages via the IOPub thread.
add_timeout isn't threadsafe, use add_callback to schedule timeout
not present in pyzmq's bundled IOLoop
Copy link
Member

Choose a reason for hiding this comment

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

I think __setattr__ should also be doing a check like this (though it should call super, rather than raising AttributeError).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, and super'd

minrk added 4 commits January 19, 2016 15:07
there appear to be no uses of this in ipykernel, at least.
- remove now-trivial IOStream._check_mp_mode
- clarify placeholder comment
takluyver added a commit that referenced this pull request Jan 19, 2016
publish IOPub from a background thread
@takluyver takluyver merged commit 60f5811 into ipython:master Jan 19, 2016
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.

Run IOPub in a thread Parallel printing to stderr

2 participants