detect run all cells

42 views
Skip to first unread message

John

unread,
Nov 24, 2017, 4:20:16 PM11/24/17
to Project Jupyter
From python code in an ipython notebook cell is it possible to detect how the cell was executed. For instance is the cell being executed from a "shift enter" command or from a "run all cells" command. 

Thanks

John

Matthias Bussonnier

unread,
Nov 24, 2017, 4:43:10 PM11/24/17
to jup...@googlegroups.com
Hi John,

No, you cannot detect that. The kernel is not even aware of whether it
is ran from a notebook or any other interface that may not have cells.
Maybe if you shared what you are trying to achieve we can find another solution.

Thanks,
--
Matthias
> --
> 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+u...@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/7cc52ae0-22b3-40c1-9815-45e7059ffd77%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

John

unread,
Nov 24, 2017, 7:44:42 PM11/24/17
to Project Jupyter
I have a python cell that runs a long duration simulation and moves objects on a canvas on the front end. I would like to receive and process messages from the front end over a Comm channel while the python code is executing in a cell. Such as a mouse event when a user clicks on the canvas element and a message is sent over Comm to the python side. Is there a mechanism in ipython/notebook that will allow me to process a message from the front end while my python code is executing in a cell such as in a while loop that runs forever.

Thanks

John

Jason Grout

unread,
Nov 30, 2017, 7:51:51 PM11/30/17
to jup...@googlegroups.com
You can run your long-running code in a separate thread, so that your kernel will be able to respond to comm messages. If your long-running code is running in the main thread, that will block the message processing and your comm messages won't be processed.

Jason


Reply all
Reply to author
Forward
0 new messages