cadquery-server
cadquery-server copied to clipboard
Watchdog thread is dead when it's conflict with save
Sometime the watchdog thread is dead when save the module from editor and stop updating UI anymore.
Steps to produce:
- Build docker image from head of this repository.
- Run cadquery-server in docker.
- Edit a module by editor (In my case I use Vim)
- Keep editing and saving (This was happen in once a 10 min or so)
What I got:
Exception in thread Thread-1 (watchdog):
Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.10/site-packages/cq_server/server.py", line 73, in watchdog
last_updated_file = module_manager.get_last_updated_file()
File "/usr/local/lib/python3.10/site-packages/cq_server/module_manager.py", line 97, in get_last_updated_file
module_path, timestamp = self.get_most_recent_module()
File "/usr/local/lib/python3.10/site-packages/cq_server/module_manager.py", line 83, in get_most_recent_module
timestamp = op.getmtime(module_path)
File "/usr/local/lib/python3.10/genericpath.py", line 55, in getmtime
return os.stat(filename).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/data/main.py'
Why this happen:
Some editor like vim do follow steps when save: (When I edit main.py)
- Rename existing main.py to main.py~
- Write new content to main.py
- Remove main.py~
When the watchdog thread call op.getmtime after 1 but before 2, the main.py is not exist.
I think we can ignore this error and retry in next tick.
Thanks