Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

views: issue warning on use of .daemonize #457

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion doc/content/demos/daemonized-view/daemonized-view.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def handle_request(self, request):
)

# tell Lona to not kill the view when the page gets refreshed
self.daemonize()
self.is_daemon = True

while True:
self.show(html)
Expand Down
6 changes: 6 additions & 0 deletions lona/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from lona.connection import Connection
from lona.channels import Channel
from lona.request import Request
import lona.warnings

# avoid import cycles
if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -349,6 +350,11 @@ def sleep(self, delay: float, result: T | None = None) -> T | None:
def daemonize(self) -> None:
# TODO: remove in 2.0

lona.warnings.warn( # NOQA: G010
'.daemonize() is deprecated, use .is_daemon = True\n (see: https://lona-web.org/1.x/api-reference/views.html#lonaview-daemonize)',
lona.warnings.DaemonizeDeprecationWarning,
stacklevel=2,
)
self.is_daemon = True

def ping(self) -> Literal['pong']:
Expand Down
8 changes: 8 additions & 0 deletions lona/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ class DictResponseDeprecationWarning(PendingDeprecationWarning):
orginal_warnings.simplefilter(
'once', category=DictResponseDeprecationWarning,
)

class DaemonizeDeprecationWarning(PendingDeprecationWarning):
pass


orginal_warnings.simplefilter(
'once', category=DaemonizeDeprecationWarning,
)
Loading