Eel: Cleanly close app

Created on 16 Mar 2020  路  4Comments  路  Source: ChrisKnott/Eel

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.

help wanted

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)

All 4 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

04fsnape picture 04fsnape  路  4Comments

HorrifyingMonkey picture HorrifyingMonkey  路  4Comments

sameera-madushan picture sameera-madushan  路  3Comments

abdurahman-shiine picture abdurahman-shiine  路  3Comments

axl3blaz3 picture axl3blaz3  路  4Comments