<div dir="ltr">Yuck :( but I am not surprised at this...<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br><br></div><div>I believe this is because all widgets seem to share the same iopub_socket and write to it whenever the user changes a traitlet.  And of course zmq sockets aren't threadsafe.</div><div><br></div></div></blockquote><div><br></div><div>Yep, they definitely share a single iopub socket.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>=== A few potential solutions === </div><div class="gmail_extra"><br></div><div class="gmail_extra">1) "Quick" -- Wrap iopub_socket in a threadsafe wrapper.  Surround every important function call in a mutex.</div></div></blockquote><div><br></div><div>Probably my second choice.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">2) "Hintjens-approved" -- Give every single widget its own inproc PUB socket.  We'd have to spin up an extra thread (or a greenlet in some pre-extant thread?  I don't really understand what the different IPython threads do...but I could find out...) with a SUB socket to collect them all together and forward them all out on iopub_socket.</div></div></blockquote><div><br></div><div>Definitely not going to happen. One of the issues we are running into, especially in multiuser deployments of the notebook is that file descriptors get consumed. If anything we are wanting to *reduce* the number of sockets used by ipython.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">3) "Dirty" -- Wrap IPython.kernel.zmq.session.Session.send inside a mutex.  Are there use-cases where anybody besides Session actually does anything with iopub_socket?</div><div class="gmail_extra"><br></div></div></blockquote><div><br></div><div>There shouldn't be any other way that send gets called, so this is probably my top choice.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"></div><div class="gmail_extra">=== Motivation ===</div><div class="gmail_extra"><br></div><div class="gmail_extra">I think there could be valid use-cases for widgets which display results from polling external resources, e.g. widgets which keep track of EC2 instances, widgets which monitor IPython.parallel workerbees, etc.</div><div class="gmail_extra"><br></div></div></blockquote><div><br></div><div>I have already started to use widgets with threads, but in my case I didn't quite run into issue you are seeing - almost though. This is definitely going to show up more.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"></div><div class="gmail_extra">=== Conclusion ===</div><div class="gmail_extra"><br></div><div class="gmail_extra">I'd be happy to attack this problem, if you guys think it would be useful.  If so, let me know what would be a good general direction, and I'll put together a pull request.</div></div></blockquote><div><br></div><div>@minrk is our expert on the zeromq stuff. Can you open an issue on the ipython/ipython repo and mention @minrk and @ellisonbg and @jdfreder</div><div><br></div><div>Thanks!</div><div><br></div><div>Brian</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">Keep warm!</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class=""><div style="font-size:12.7272720336914px">Jackson Loper</div><div style="font-size:12.7272720336914px">Pattern Theory Group</div><div style="font-size:12.7272720336914px">Division of Applied Math</div><div style="font-size:12.7272720336914px">Brown University</div><div style="font-size:12.7272720336914px"><br></div></span><div style="font-size:12.7272720336914px">PS. I love the new text editor feature in the ipython master branch!  My days of vim-over-ssh aren't over yet (NERDTree and push-notification of filechange detection are still too useful to me when logging on from multiple machines) but I can see the end in sight!</div></div>







</div>
<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Brian E. Granger<br>Cal Poly State University, San Luis Obispo<br>@ellisonbg on Twitter and GitHub<br><a href="mailto:bgranger@calpoly.edu" target="_blank">bgranger@calpoly.edu</a> and <a href="mailto:ellisonbg@gmail.com" target="_blank">ellisonbg@gmail.com</a></div>
</div></div>