zauberzeug / nicegui

Create web-based user interfaces with Python. The nice way.
https://nicegui.io
MIT License
8.93k stars 542 forks source link

while running smoothly after few minutes this issue occurred..please help #3145

Closed cindyxyz96 closed 3 months ago

cindyxyz96 commented 4 months ago

Description

Client has been deleted but is still being used. This is most likely a bug in your application code. See https://github.com/zauberzeug/nicegui/issues/3028 for more information.
Stack (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 122, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 135, in _main
    return self._bootstrap(parent_sentinel)
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 314, in _bootstrap
    self.run()
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\uvicorn\_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\server.py", line 36, in run
    super().run(sockets=sockets)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 671, in run_until_complete
    self.run_forever()
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 638, in run_forever
    self._run_once()
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1971, in _run_once
    handle._run()
  File "C:\Users\LahiruGa\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\events.py", line 419, in wait_for_result
    await result
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\app1.py", line 3514, in main
    await check_files(base_path, input_path, template_path, output_path, rpa_affective_date)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\app1.py", line 1407, in check_files
    email_status = await send_email('Acclkcom@brandix.com', mail_to, f'Annual Increment Cycle - April {current_year}', calling_name_1, cc_emails, pdf_file)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\app1.py", line 3417, in send_email
    log.push("Mail Sent...📧🟢")
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\elements\log.py", line 27, in push
    Label(text)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\elements\label.py", line 13, in __init__
    super().__init__(tag='div', text=text)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\elements\mixins\text_element.py", line 14, in __init__
    super().__init__(**kwargs)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\element.py", line 103, in __init__
    self.client.outbox.enqueue_update(self)
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\outbox.py", line 39, in enqueue_update
    self.client.check_existence()
  File "C:\Users\LahiruGa\Desktop\Projects\Tharushi\Letter Generation\myenv\Lib\site-packages\nicegui\client.py", line 330, in check_existence
    log.warning('Client has been deleted but is still being used. This is most likely a bug in your application code. '
falkoschindler commented 4 months ago

Hi @cindyxyz96,

Have you looked into https://github.com/zauberzeug/nicegui/issues/3028 as the warning suggests? Without seeing your code, it's hard to tell what's going on. But there might be some global logger that is updating multiple ui.log elements. This causes the logger to hold these elements and their client object, causing a memory leak.

falkoschindler commented 3 months ago

I'll close this issue as stale. Feel free to re-open it once you've got new information for us. Thanks!