-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
[Windows] Python 3.12 and not properly reloading changed files #2138
Comments
Update: It doesn't even seem to be callback related, just changing the text on the ui.button in the code snippet while the app is running is enough to get the app hanging. Perhaps the Filewatcher is not Python 3.12 ready? I need to confirm if it's not a Windows/Git Bash/Python 3.12 specific issue instead of NiceGUI. Will do that as soon as I get out of work. |
my python 3.10.9 amd 64 for windows does not reload changed file too. even it says
|
Interesting, are you also using Git Bash to run your app or something else? Then again, I don't have the problem with Python 3.11.7 so I don't think it's related. |
it runs out that no matter I use python 3.10 or 3.11
but the webpage will never been updated so I think this problem lives in SciTe. However I don't know the reason |
It sounds to me like it runs as intended and it's a SciTe issue. |
Python 3.12.1 (couldn't seem to install 3.12.0 through the deadsnakes PPA) and the latest NiceGUI running on Ubuntu 22.04 seems to work just fine. I see that 3.12.1 just dropped for Windows on python.org as well. I'll check if the point release fixes it or if I need some other tests. |
Python 3.12.1 doesn't seem to fix the issue for me either, tried it in both Git Bash and cmd.exe but still the hanging occurs while filewatcher tries to pick up on file changes. I've also noticed Python 3.12+ forces admin rights during installation on Windows and Python 3.11+ does not as evidenced at the checkboxes here: Checkboxes are grayed out anyway so I unfortunately can't turn them on/off to test(on a work laptop so probably don't have full admin access to change it). Anyway I've tried to run my script both with an admin rights git bash window and one without admin rights and both didn't seem to work so I feel that the admin rights is a dead end as well. Next I tried to do it on a different machine instead of my Windows work laptop so I could exclude more things, so I spinned up a Windows 10 VM in Gnome Boxes on my Ubuntu 22.04 laptop. Already had Python 3.11.4 installed there, tried the same code snippet and it worked fine in both Git Bash/CMD. However when I installed Python 3.12+ again(this time I tried it both with/without admin rights during install) I again get the hanging filewatcher bug. @rodja @falkoschindler can one of you confirm on a Windows 10 machine if my steps-to-reproduce won't hang the filewatcher when running my code example and change the text of the button while it's running & save the file in either Git bash or cmd? Scratching my head here since it all seems to be related to the Python 3.12, NiceGUI & Windows combo. |
We are only running Mac and Linux systems here. It would be interesting if you could reproduce the behaviour with plain FastAPI and Uvicorn. |
Everything is Linux at home but unfortunately Gov IT in the Netherlands, excluding servers, is mostly Windows. I'll try to reproduce the behaviour with FastAPI/Uvicorn, good idea. Would assume it would be something along the lines of: from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def somepage():
return {"message": "Aloha"} and run it using |
Can confirm the bug is present in FastAPI/Uvicorn on Win10 with Python 3.12+ $ uvicorn test2:app --reloadINFO: Will watch for changes in these directories: ['C:\\Users\\Frinux\\Documents\\niceguitest']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [7228] using WatchFiles
INFO: Started server process [6576]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:51503 - "GET / HTTP/1.1" 200 OK
WARNING: WatchFiles detected changes in 'test2.py'. Reloading...
INFO: Shutting down
INFO: 127.0.0.1:51504 - "GET / HTTP/1.1" 200 OK
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [6576]
INFO: Started server process [7100]
INFO: Waiting for application startup.
INFO: Application startup complete. 2023-12-10.23-58-11.mp4In the video below you can see me trying to Ctrl+C to quit the running server after I do a file change, it first throws an 2023-12-11.00-00-33.mp4So I guess we can close this bug for NiceGUI itself(even though this would mean Python 3.12 isn't supported for Windows users until uvicorn or fastapi gets a fix out). |
Thanks for the extensive research, @frankhuurman! |
@frankhuurman did rolling back to a specific version of NiceGUI or/and python work for you? I'm still struggling with this |
Description
This might not be the cleanest bug report because I'll update this ticket as I go since I'm currently at work and don't want to forget to report on it whilst I'm experiencing it. Apologies in advance.
There seems to be a bug in the combo of Python 3.12 and NiceGUI (1.4.5 and lower) that in specific cases doesn't pick up on changed files and only continues execution(or show output in Git Bash on Win10) as soon as I close the current open browser tab of the NiceGUI application. Using Ctrl+C in Git Bash during this "hanging" won't stop the program either, only after I close the browser tab it seems to be able to quit the hanging process.
Because it's related to the browser tab this makes me think it's perhaps websocket or button callback related, but perhaps this could be Git Bash related as well, I'm unsure at the moment.
I've switched between Python 3.11.7 and 3.12.0 a couple of times because we want to have a stable experience for a NiceGUI based work application so we had to decide on versions. That's how I found out that 3.11.7 didn't have the bug and 3.12.0 does.
Code snippet 1 to reproduce:
Code snippet 2 to reproduce:
Steps in order to reproduce weird behaviour:
WARNING: WatchFiles detected changes in 'test.py'. Reloading...
is printed in the terminalasyncio.exceptions.CancelledError
or aKeyboardInterrupt
with sometimes the line "NiceGUI ready to go on http://localhost:8080, http://10.107.239.140:8080, http://10.13.192.176:8080, http://172.24.176.1:8080, http://172.24.208.1:8080, and http://192.168.56.1:8080" again before the app actually closes (sometimes it also keeps running but most of the time it closes)The text was updated successfully, but these errors were encountered: