[IPython-dev] threadsafe widgets
jackson_loper at brown.edu
Thu Jan 8 22:28:03 EST 2015
It is my understanding that the traitlets in most ipython notebook widgets
aren't threadsafe. If you're not sure what I mean, I attached a small
example at the bottom of this note.
What's the best way for me to make a threadsafe widget? I could inherit
from DOMWidget and override a whole bunch of methods with a wrapper that
puts things inside a threading.Lock, but it seems kinda like overkill. I
suppose theoretically you could lock all the traitlets & comms calls, but
that also seems like overkill. Or maybe not...I have no sense of
proportion for these things.
The application is straightforward, maybe there's an easier way to do it.
I'd like to be able to edit files from jupyterhub's host directly inside
the notebook; CodeMirror is much more responsive than vim over ssh. It was
easy to make a text-editing widget based on codemirror, but I'd like to pop
up a CodeMirror.dialog if somebody has changed the file being edited.
Can't figure out how to do that in a threadsafe way.
Pattern Theory Group
Division of Applied Math
====== threadsome danger =====
Running the latest github clone of jupyterhub, code like this is a very bad
from IPython.html import widgets, nbextensions
from numpy.random import randint
for i in range(N):
The jupyterhub logs errors such as
Malformed message: [b'comm-....', b'<IDS|MSG>', b'comm-...', b'<IDS|MSG>',
... more stuff.. ]
Presumably two attempts at sending data over comms got mixeduptogether
here, which is why we ended up with two <IDS_MSG> in one message!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev