Skip to content
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

Watchdog thread is dead when it's conflict with save #74

Open
ikeji opened this issue Jan 12, 2023 · 0 comments
Open

Watchdog thread is dead when it's conflict with save #74

ikeji opened this issue Jan 12, 2023 · 0 comments

Comments

@ikeji
Copy link

ikeji commented Jan 12, 2023

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)

  1. Rename existing main.py to main.py~
  2. Write new content to main.py
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant