Getting a proper LogView to avoid Client has been deleted but is still being used #3513
Replies: 3 comments 1 reply
-
I think the problem isn't that you're pushing to But I can't say for sure without seeing how the log handler is used. |
Beta Was this translation helpful? Give feedback.
-
@falkoschindler thank you for looking into this what would be the proper design? async def setup_footer(
self,
with_log: bool = True,
handle_logging: bool = True,
max_lines: int = 20,
log_classes: str = "w-full h-40",
):
"""
setup a footer with an optional log view
"""
if with_log:
self.log_view = LogView(max_lines=max_lines, classes=log_classes)
if handle_logging:
self.log_view.addAsHandler(self.logger)
else:
self.log_view = None
await super().setup_footer()
if self.args.input:
# await client.connected()
with_render = self.render_on_load
await self.read_and_optionally_render(
self.args.input, with_render=with_render
)
which is handled by a WebSolution which is effectively a wrapper for a client. The WebSolution could have proper synchronization with the Clients lifecycle. What is the official Client lifecycle and why do i get "The Client has been deleted" as an Exception right in the push action? class InputWebSolution(WebSolution):
"""
A WebSolution that is focused on handling a single input.
Attributes:
is_local (bool): Indicates if the input source is local or remote.
input (str): The input data or path to be processed.
"""
def __init__(self, webserver: NiceGuiWebserver, client: Client):
"""
Initializes the InputWebSolution instance with the webserver and client.
Args:
webserver (NiceGuiWebserver): The webserver instance this solution is part of.
client (Client): The client interacting with this solution.
"""
super().__init__(webserver, client) |
Beta Was this translation helpful? Give feedback.
-
That means that my current assumption is wrong. I currently have WebServer and WebSolution as the core elements. A WebServer is handling the environment for a certain project and listens on a certain port. A WebSolution is for handling clients and i was under the assumption that this is stable for a "session" - but there is no real session concept here so we have to go on the Request level which means there are three levels of state handling necessary. Technical that means port/socket/request and i would love to handle this in a more abstract and generic way that does hide the technical details. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
The log handling with ui.log recently gave me trouble recently with Client has been deleted but is still being used see WolfgangFahl/nicegui_widgets#70.
I would love to properly handle this and for the time being simply try to switch off and logging via ui.log and only keep the fallback handler which logs to stderr so that i can continue debugging. This implementation seems to still not be fail safe. So how can i check whether ui.log can be pushed to? Would it be a feature request to make sure ui.log.push() checks this for itself?
log_view module from https://github.com/WolfgangFahl/nicegui_widgets/blob/main/ngwidgets/log_view.py
Beta Was this translation helpful? Give feedback.
All reactions