Is there a clean way of stopping the bottle server from running when the app window has been closed? Python process is left open when the window is closed. I'm assuming this is the bottle server that is still running.
Discovered more information, which may be known already but wanted to provide my findings.
I appears that gevent is looping to keep the window open. When I interrupted the script, this traceback displayed.
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\gevent\_ffi\loop.py", line 234, in python_check_callback
def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument
I had this problem (closing the window not closing the app) when I first started, but it turned out that I had not added the eel.js to my HTML page. Once I added that, the closing of the window seemed to properly send the sys.exit (which you can let happen or use a try/except on)
As mentioned by patter001, an option is to do a try/catch in my case i manually close the python.exe process on except:
try:
#Start the application and pass all initial params below
eel.start(....)
except (SystemExit, MemoryError, KeyboardInterrupt):
#Handle errors and the potential hanging python.exe process
os.system('taskkill /F /IM python.exe /T')
This may be overkill or not necessary in some cases, but works for me in Windows 10.
I'm going to close this based on @patter001's comment. Eel should definitely be shutting down when the last websocket connection closes - if this isn't happening, please submit a new issue as a bug report with code (ideally a link to an open github repo) so that we can reproduce and investigate. Thanks!
Most helpful comment
I had this problem (closing the window not closing the app) when I first started, but it turned out that I had not added the eel.js to my HTML page. Once I added that, the closing of the window seemed to properly send the sys.exit (which you can let happen or use a try/except on)