The solution did indeed involve asyncio, thanks to detailed advice from
John Coady.

The vpython module now (released two days ago) detects whether it is
running in a Jupyter notebook or not. When running outside the Jupyter
notebook environment it sets up an http server to serve image files (for
textures on 3D objects) and font files (for extruding 3D text), and it sets
up a websocket server for rapid two-way communications between the Python
program and a JavaScript program in the browser that calls upon the
GlowScript library for WebGL rendering. The websocket code uses asyncio.
The most challenging issue was dealing with possible conflicts between the
websocket thread and the main program, and the solution involved making
sure the main program added data to be transmitted by the websocket only
with "atomic" statements such as appending to a list or adding to a set. In
some cases the websocket approach seems to run significantly faster than
the Jupyter communication mechanism.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CA%2BWuaSdNxqsh2BJ73WhNQ323jbLAjap0Btahtxgv1_g%2BarVjDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to