zauberzeug / nicegui

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

Reload slow, no response to ctrl-C on Windows #3652

Open superlou opened 2 weeks ago

superlou commented 2 weeks ago

Description

A simple application starts up in a second or two, but on making a change, reloading may take 10 seconds or more and may hang. Additionally, when hung, the terminal (both PowerShell and CMD) has no response to ctrl-c or clicking the close button. It's been about a year since I've used NiceGUI on Windows (I mostly use Linux) and I don't remember this behavior before.

It sounds a bit like https://github.com/zauberzeug/nicegui/issues/3344, but this isn't in PyCharm. There are also some issues in uvicorn like https://github.com/encode/uvicorn/issues/1972 that sound related, but I know enough about the NiceGUI stack to know if that could be the root cause.

My test script is:

from nicegui import ui

ui.button("Button 1")
ui.button("Button 2")
ui.button("Button 3")

ui.run()

Steps to recreate:

  1. Make a simple NiceGUI script like the above named simple.py.
  2. Run python simple.py in a Windows terminal.
  3. Comment out one of the ui.button(...) calls and save the file.
  4. Wait for "... Reloading..." to complete and show "NiceGUI ready to go..."

Environment:

Edit: I tried the same test in WSL2 on the same computer and reloads are very fast, under a second.

rodja commented 2 weeks ago

Wow. That sounds serious. We aim for a super fast reload. Can anyone else with Windows reproduce this?

python-and-fiction commented 1 week ago

@superlou do you test it in pure termial or in ide's integrated terminal? It soulds like similar bug in pycharm or in vscode i met.

superlou commented 1 week ago

I was testing in a pure terminal, both Powershell and CMD had similar behavior (as well as Microsoft Terminal running Powershell).

frankhuurman commented 4 days ago

@superlou This might be a bit skewed because I'm using Windows 10 in a VM but for me with the nicegui version you specified and running your code example in cmd.exe it takes about 5 seconds on average to reload the page during file saves. Using Git Bash takes about 4 seconds on average though it has trouble handling Ctrl + C for me as well.

On Linux it's nearly instant for me so seems to be a very Windows-y problem.

Upgrading to the latest NiceGUI version doesn't seem to change anything speed-wise either so it might be related to the way filewatcher picks up on filechanges on Windows in comparison to the other OS-es?