Since I've posted ill-formed questions several times I'd like to pay 
patient readers back by describing a successful answer to something that 
might affect others.

In Jupyter VPython (see vpython.org) data is sent from a Python program to 
a JavaScript program and is processed by the GlowScript WebGL library to 
display 3D animations in the notebook. There are restrictions on sending 
data from a Python thread, and I even found a disastrous case where early 
data sent from within a Python thread arrived in the browser after later 
data sent from outside that thread, yet there seemed no way to avoid the 
necessity of a thread that would interrupt and send data about 30 times per 
second.

A robust solution turned out to be the following: The JavaScript program 
sends an event to Python, which calls a Python program that sends data (if 
any) to the JavaScript program and in all cases sends a message requesting 
that the JavaScript program set a timer to send Python another event 1/30th 
of a second from now. In that way there is no thread in the Python program, 
so data transmissions are not sent from within a Python thread. 

One might think that the JavaScript program could set an interval timer to 
send the wakeup message regularly to Python. However, when I tried that 
scheme it turned out to be very difficult to rerun or kill a program. 
Apparently killing the kernel doesn't stop JavasScript timeouts. Doing the 
full roundtrip handshake assures that the JavaScript program will not keep 
running if the Python program is killed.

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/0fa98b9e-9a54-4117-bb99-b4937c9cd9c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to