Closed russkel closed 5 years ago
It's certainly true that this area needs work. Thanks for the specific suggestion.
I modified no_notebook.py file to fix this problem and I checked it into github repository.
https://github.com/BruceSherwood/vpython-jupyter/tree/master/vpython
You can now type "CTRL+C" at the terminal window to terminate the vpython program in no_notebook mode or close the browser tab where the vpython program is running.
John
From: "BruceSherwood" notifications@github.com To: "BruceSherwood/vpython-jupyter" vpython-jupyter@noreply.github.com Cc: "Subscribed" subscribed@noreply.github.com Sent: Saturday, March 10, 2018 4:54:41 PM Subject: Re: [BruceSherwood/vpython-jupyter] No nice way to stop vpython in no_notebook mode (#36)
It's certainly true that this area needs work. Thanks for the specific suggestion.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or mute the thread .
Thanks a lot for this John. I will have a test later today and get back to you.
I made an additional change to no_notebook.py and also a change to glowcomm.html . Ctrl+C only works if the main python thread is still running such as in a long running vpython program, and so if you perform Ctrl+C in this case then the prompt will be returned in the terminal window and the browser tab will be closed. If the main python thread has completed and the threads are still running then Ctrl+C doesn't work but if you manually close the browser tab window then the prompt will be returned in the terminal window. You can pick up the changes to these files on github.
https://github.com/BruceSherwood/vpython-jupyter/tree/master/vpython
https://github.com/BruceSherwood/vpython-jupyter/tree/master/vpython/vpython_libraries
John
From: "Russ" notifications@github.com To: "BruceSherwood/vpython-jupyter" vpython-jupyter@noreply.github.com Cc: "johncoady" johncoady@shaw.ca, "Comment" comment@noreply.github.com Sent: Monday, March 12, 2018 3:30:45 PM Subject: Re: [BruceSherwood/vpython-jupyter] No nice way to stop vpython in no_notebook mode (#36)
Thanks a lot for this John. I will have a test later today and get back to you.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub , or mute the thread .
There still doesn't seem to be a way to programmatically terminate vpython. Any possibility of getting a function that does that?
I added this to the 7.5.0 milestone since @russkel gave us a nicely specific suggestion for how we would need to implement the feature. There may be some issues with closing down the async loop if we are running in a notebook or in IPython >=7, but those should be manageable.
@russkel -- there is now a stop_server
command (see #102); it would require these two steps to invoke it:
from vpython.no_notebook import stop_server
stop_server()
Does that work for you?
I'm going to go ahead and close this -- if you find it doesn't work for you @russkel please do feel free to reopen the issue or to open a new issue, and thanks again for reporting it!
I haven't had a VPython project in some time, but I am glad to see this has made it through! Thanks for your work all.
I'm using a recent wheel from PyPI (using win7, Python 3.6.5, I got VPython 7.4.7); the stop_server() function isn't appearing in my no_notebook module, and the dundered calls from the original poster aren't working for me either (but raise no exceptions). I was able to emulate the Ctrl+C, though, and that works for me. Hopefully someone else will find it useful.
import os
import signal
os.kill(os.getpid(), signal.SIGINT)
I recently dusted off a lot of my old projects, and some VPython code was in there. I'm really glad to see that it's still under active development, and I'm pretty excited about the new possibilities provided by GlowScript.
Thanks! That does seem to work.
@sfaleron -- if you upgrade to vpython 7.5.0 or higher then stop_server()
will work. It is one of the new features introduced in that version.
I gathered that, and I'll try it on my Linux machine.
Please open an issue if it doesn't work.
Thanks for the update ! I'll finally be able to throw away that TODO :smile:
I noticed my script was never terminating after running in a no_notebook setup, and after some digging I found out I had to call this to terminate the program:
I don't know the code base well so I can't offer a suggestion as to where/how, but can this be put in a function that gracefully stops vpython?
vp.shutdown()
or something?