Skip to content
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ As of Eel v0.12.0, the following options are available to `start()`:
- **close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`*
- **app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the
instance before starting eel, e.g. for session management, authentication, etc.
- **shutdown_delay**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `shutdown_delay` seconds, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. Default: `1.0`



Expand Down
6 changes: 5 additions & 1 deletion eel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'disable_cache': True, # Sets the no-store response header when serving assets
'default_path': 'index.html', # The default file to retrieve for the root URL
'app': btl.default_app(), # Allows passing in a custom Bottle instance, e.g. with middleware
'shutdown_delay' : 1.0 # how long to wait after a websocket closes before detecting complete shutdown
}

# == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 ===
Expand Down Expand Up @@ -153,6 +154,9 @@ def start(*start_urls, **kwargs):
_start_args['jinja_env'] = Environment(loader=FileSystemLoader(templates_path),
autoescape=select_autoescape(['html', 'xml']))

# verify shutdown_delay is correct value
if not isinstance(_start_args['shutdown_delay'], (int, float)):
raise ValueError(f"`shutdown_delay` must be a number, got a {type(_start_args['shutdown_delay'])}")

# Launch the browser to the starting URLs
show(*start_urls)
Expand Down Expand Up @@ -380,7 +384,7 @@ def _websocket_close(page):
if _shutdown:
_shutdown.kill()

_shutdown = gvt.spawn_later(1.0, _detect_shutdown)
_shutdown = gvt.spawn_later(_start_args['shutdown_delay'], _detect_shutdown)


def _set_response_headers(response):
Expand Down