Skip to content

Commit

Permalink
views: fix handling of View.is_daemon
Browse files Browse the repository at this point in the history
This patch is a fixup for

    94587cc ("views: fix handling of `View.is_daemon`")

The original patch did not fix the bug entirely. This patch adds a test
to reproduce the original problem, and fixes it by adding a check for the
feature flag.

Signed-off-by: Florian Scherf <[email protected]>
  • Loading branch information
fscherf committed Feb 10, 2023
1 parent 4b97165 commit 59c767f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lona/view_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,13 @@ def remove_connection(self, connection, window_id=None):

# if the last connection gets closed and the view should
# not continue running in background, it gets stopped
if (not self.connections and
self.stop_daemon_when_view_finishes and
not self.is_daemon):
if not self.connections and not self.is_daemon:
self.stop()

# TODO: remove in 2.0
elif (self.stop_daemon_when_view_finishes and
self.is_stopped and
not self.connections):

self.stop()

Expand Down
10 changes: 10 additions & 0 deletions tests/test_daemon_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def handle_request(self, request):

assert message3 == 'view stopped'

# check if views got removed from the server
await page.goto('about:blank')

for attempt in eventually():
async with attempt:
view_runtime_count = len(
context.server._view_runtime_controller._view_runtimes)

assert view_runtime_count == 0


async def test_multi_tab_daemon_view(lona_app_context):
"""
Expand Down

0 comments on commit 59c767f

Please sign in to comment.