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

auto restart in watchdog==2.1.6 #855

Closed
pe-terminator opened this issue Nov 10, 2021 · 15 comments · Fixed by #888
Closed

auto restart in watchdog==2.1.6 #855

pe-terminator opened this issue Nov 10, 2021 · 15 comments · Fixed by #888

Comments

@pe-terminator
Copy link

pe-terminator commented Nov 10, 2021

Hey dawgs,

There appears to be an issue with v2.1.6 specific to having a auto-restart flag when initiating watchdog using the following command:

watchmedo auto-restart -- python -u some_python_file.py

Here is the error from the console:
image

Reverting to 2.1.5 fixed the issue. Hopefully the issue will be resolved in the upcoming release.

Cheers,

@BoboTiG
Copy link
Collaborator

BoboTiG commented Nov 11, 2021

Maybe related to #836, would you mind to have a quick look @lorenzobn 🙏 ?

@dtcooper
Copy link

dtcooper commented Nov 11, 2021

Did some poking around, and maybe this will help.

I traced it somewhat to line 174 watchdog/tricks/__init__.py,

def start(self):
    # windows doesn't have setsid
    self.process = subprocess.Popen(self.command, preexec_fn=getattr(os, 'setsid', None))

Where self.command is auto-restart and NOT the command to watch in Python 3.9 (works on Python 3.10 for some reason).

Also getting this error, but with shell-command as well. Perhaps related.

$ watchmedo shell-command --patterns='*.py' --command='echo "${watch_src_path}'
# on save of a .py file
/bin/sh: 1: shell-command: not found
/bin/sh: 1: shell-command: not found
/bin/sh: 1: shell-command: not found

Reverting to 2.1.5 fixes this for now.

@lorenzobn
Copy link
Contributor

Maybe related to #836, would you mind to have a quick look @lorenzobn 🙏 ?

I'll do it as soon as I can 👍

@lorenzobn
Copy link
Contributor

I tried to reproduce the errors reported by @Pirate-Pete and @dtcooper on watchdog 2.16. Unfortunately, I wasn't able to replicate them.
Could you please write a step-by-step description, with general information such as your OS and python version, so that I can reproduce the error?

@ildarworld
Copy link

I tried to reproduce the errors reported by @Pirate-Pete and @dtcooper on watchdog 2.16. Unfortunately, I wasn't able to replicate them.
Could you please write a step-by-step description, with general information such as your OS and python version, so that I can reproduce the error?

that's can be easily reproduced in docker by using python:3.9.6-slim image

in docker-compose file I have tried like this:

command: sh -c "watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- python main.py"

@lorenzobn
Copy link
Contributor

@ildarworld Do you have a screenshot or something about the error? Is it a FileNotFoundException similar to the image provided by @Pirate-Pete the kind of error you get?

@BoboTiG
Copy link
Collaborator

BoboTiG commented Dec 15, 2021

Hmm I cannot reproduce either using watchmedo 2.1.6, and unreleased, versions. Using Python 3.9.9 🤔

@sopi20
Copy link

sopi20 commented Dec 22, 2021

Hi, I have the same problem with 2.1.6., reverting to 2.1.5 makes it work again (probably related to getting rid of argh dependency in 2.1.6, and somewhat different behaviour with current parser).

Traceback (most recent call last):    
  File "/usr/local/bin/watchmedo", line 33, in <module>    
    sys.exit(load_entry_point('watchdog==2.1.6', 'console_scripts', 'watchmedo')())    
  File "/usr/local/lib/python3.9/site-packages/watchdog/watchmedo.py", line 641, in main    
    args.func(args)    
  File "/usr/local/lib/python3.9/site-packages/watchdog/watchmedo.py", line 625, in auto_restart    
    handler.start()    
  File "/usr/local/lib/python3.9/site-packages/watchdog/tricks/__init__.py", line 174, in start    
    self.process = subprocess.Popen(self.command, preexec_fn=getattr(os, 'setsid', None))    
  File "/usr/local/lib/python3.9/subprocess.py", line 951, in _init_    
    self._execute_child(args, executable, preexec_fn, close_fds,    
  File "/usr/local/lib/python3.9/subprocess.py", line 1821, in _execute_child    
    raise child_exception_type(errno_num, err_msg, err_filename)    
PermissionError: [Errno 13] Permission denied: 'auto-restart'

I also had some issue with option arguments that did not expect any value to expect it in 2.1.6 (probably due to the same reason):

usage: watchmedo auto-restart [-h] [-d directory] [-p PATTERNS]    
                              [-i IGNORE_PATTERNS] [-D] [-R]    
                              [--interval TIMEOUT] [--signal SIGNAL]    
                              [--debug-force-polling DEBUG_FORCE_POLLING]    
                              [--kill-after KILL_AFTER]    
                              command [arg ...]    
watchmedo auto-restart: error: argument --debug-force-polling: expected one argument

Python version is 3.9.8, OS is FreeBSD, command line I'm using is:

watchmedo auto-restart --directory=<directory> --pattern=<directory> --signal=SIGTERM --debug-force-polling -- celery <celery_arguments>

@kozlovzxc
Copy link

Any help needed to reproduce this?

Error

Traceback (most recent call last):
  File "/Users/kozlovzxc/.local/share/virtualenvs/app-QadN2i4i/bin/watchmedo", line 8, in <module>
    sys.exit(main())
  File "/Users/kozlovzxc/.local/share/virtualenvs/app-QadN2i4i/lib/python3.9/site-packages/watchdog/watchmedo.py", line 641, in main
    args.func(args)
  File "/Users/kozlovzxc/.local/share/virtualenvs/app-QadN2i4i/lib/python3.9/site-packages/watchdog/watchmedo.py", line 625, in auto_restart
    handler.start()
  File "/Users/kozlovzxc/.local/share/virtualenvs/app-QadN2i4i/lib/python3.9/site-packages/watchdog/tricks/__init__.py", line 174, in start
    self.process = subprocess.Popen(self.command, preexec_fn=getattr(os, 'setsid', None))
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'auto-restart'

Python version

3.9.8

Watchmedo version

"index": "pypi",
"version": "==2.1.6"

@taleinat
Copy link
Contributor

taleinat commented May 12, 2022

This may be caused by using "command" both as the name for the argparse sub-parsers destination (watchmedo.py line 71) as well as the command to run (line 524).

Note that the same is true for watchmedo shell-command.

@BoboTiG
Copy link
Collaborator

BoboTiG commented May 13, 2022

I am on it!

@BoboTiG
Copy link
Collaborator

BoboTiG commented May 13, 2022

I also had some issue with option arguments that did not expect any value to expect it in 2.1.6 (probably due to the same reason):

usage: watchmedo auto-restart [-h] [-d directory] [-p PATTERNS]    
                              [-i IGNORE_PATTERNS] [-D] [-R]    
                              [--interval TIMEOUT] [--signal SIGNAL]    
                              [--debug-force-polling DEBUG_FORCE_POLLING]    
                              [--kill-after KILL_AFTER]    
                              command [arg ...]    
watchmedo auto-restart: error: argument --debug-force-polling: expected one argument

Fixed with #887.

@BoboTiG
Copy link
Collaborator

BoboTiG commented May 13, 2022

I am still unable to reproduce the original issue with Python 3.10.4 and watchdog 2.1.7 (and unreleased).

@BoboTiG
Copy link
Collaborator

BoboTiG commented May 13, 2022

OK I finally reproduced on Python 3.9.8. What whatever magical reason, the bug is not triggered on Python 3.10. Working on a fix, thanks to @taleinat for the hint ;)

@BoboTiG
Copy link
Collaborator

BoboTiG commented May 13, 2022

Could someone confirm that the version from the master branch does fix those issues, 🙏?
If so, I'll publish a new release ASAP.

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

Successfully merging a pull request may close this issue.

8 participants