display() in imported file fails with pypy kernel

43 views
Skip to first unread message

John

unread,
Oct 19, 2017, 3:37:57 PM10/19/17
to Project Jupyter
I have jupyter installed on an ubuntu linux machine using Anaconda with Python 3. I also installed pypy and pypy3 on the ubuntu linux machine and configured them as kernels for the Jupyter notebook. When I open a notebook I am able to switch between the 3 kernels, namely Python3 , PyPy and PyPy3. The problem I am having is that the following import statement fails when PyPy is configured as the kernel for the notebook.

from test import *

executing this line in a notebook cell fails when PyPy is the kernel for the notebook, but it works fine when the notebook is configured to have the PyPy3 kernel or the Python3 kernel. It also works fine when Python2 is the kernel. The contents of the test.py file is the following.

import IPython
from IPython.core.display import Javascript
display(Javascript("""console.log('hello')"""))
a = 1
display(a)

When I execute the cell containing

from test import *

when PyPY is the kernel the cell execution never completes and the * symbol remains displayed to the left of the cell indefinitely.


John

unread,
Oct 29, 2017, 7:43:23 PM10/29/17
to Project Jupyter
I reported this issue at pypy here


and they debugged it to a certain point and are wondering if some IPython experts can shed some light on problem.

> pypy2-v5.9.0-linux64/site-packages/ipykernel/iostream.py(319)flush()
-> evt = threading.Event()
(Pdb) n
> pypy2-v5.9.0-linux64/site-packages/ipykernel/iostream.py(320)flush()
-> self.pub_thread.schedule(evt.set)
(Pdb) n
> pypy2-v5.9.0-linux64/site-packages/ipykernel/iostream.py(321)flush()
-> evt.wait()

John

MinRK

unread,
Oct 30, 2017, 9:48:39 AM10/30/17
to Project Jupyter

The additional light I can shed is that IOPub is handled via a background IO thread. When you display/print/etc., we handoff messages to be sent on the IO thread. When .flush() is called, a Python threading.Event is used to synchronize with the thread to ensure that any past sends have actually occurred. Something in the import mechanism is preventing this background thread from waking. This PR should prevent us from waiting for a flush event during imports.

-Min


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/8b5c051f-ed37-4bdc-8d0e-d63813398510%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

John

unread,
Nov 3, 2017, 12:50:11 PM11/3/17
to Project Jupyter
Hi Min

  Can you fix this PR https://github.com/ipython/ipykernel/pull/276 that you created the other day. You added the line 

if not evt.wait(self.FLUSH_TIMEOUT):

but you defined FLUSH_TIMEOUT in a different class, not the one where it is used.


John
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages