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 On Fri, Nov 24, 2017 at 4:44 PM John <[email protected]> wrote: > 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 > > > On Friday, November 24, 2017 at 1:43:10 PM UTC-8, Matthias Bussonnier > wrote: > >> 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 >> >> >> On Fri, Nov 24, 2017 at 10:20 PM, John <[email protected]> wrote: >> > 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 >> > >> > -- >> > 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/7cc52ae0-22b3-40c1-9815-45e7059ffd77%40googlegroups.com. >> >> > For more options, visit https://groups.google.com/d/optout. >> > -- > 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/61f5ca4d-97ec-4c01-8a3e-5796ad3d12f7%40googlegroups.com > <https://groups.google.com/d/msgid/jupyter/61f5ca4d-97ec-4c01-8a3e-5796ad3d12f7%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAPDWZHy5ESq6F1QdWbjRtgzuH3%3DuKXEtBzb7a7oLbHMkPA-a1Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
