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

Dose crashes on OSError raised by watchdog #15

Open
danilobellini opened this issue Nov 27, 2016 · 0 comments
Open

Dose crashes on OSError raised by watchdog #15

danilobellini opened this issue Nov 27, 2016 · 0 comments

Comments

@danilobellini
Copy link
Owner

Dose should deal with exceptions that comes from the watchdog observer, like:

OSError: inotify watch limit reached
OSError: Permission denied

These errors are triggered when the watchdog.observers.Observer.start method is called for an instance that is scheduled to watch something it couldn't watch. Similar to runner exceptions, Dose should give a proper message instead of crashing.

On Linux, when running Dose on a directory that has way too many subdirectories, watchdog raises an OSError because inotify has a limit on the number of watchers, and watchdog puts a watcher on every subdirectory:

$ mkdir /tmp/crash_dose
$ cd /tmp/crash_dose
$ cat /proc/sys/fs/inotify/max_user_watches | xargs seq | xargs mkdir
$ dose echo -n
                 *** First call ***
====================================================
         [Dose] 2016-11-27 04:10:53.223946
====================================================
Traceback (most recent call last):
  [...]
  File "/usr/lib/python2.7/site-packages/dose/_legacy.py", line 487, in start
    self._watcher.__enter__() # Returns a started watchdog.observers.Observer
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/lib/python2.7/site-packages/dose/watcher.py", line 34, in watcher
    observer.start()
  [...]
  File "/usr/lib/python2.7/site-packages/watchdog/observers/inotify_c.py", line 402, in _raise_error
    raise OSError("inotify watch limit reached")
OSError: inotify watch limit reached

A really simple way to get an OSError is to run Dose on /:

$ cd /
$ dose echo -n
                 *** First call ***
====================================================
         [Dose] 2016-11-27 04:10:53.223946
====================================================
Traceback (most recent call last):
  [...]
  File "/usr/lib/python2.7/site-packages/dose/_legacy.py", line 487, in start
    self._watcher.__enter__() # Returns a started watchdog.observers.Observer
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/lib/python2.7/site-packages/dose/watcher.py", line 34, in watcher
    observer.start()
  [...]
  File "/usr/lib/python2.7/site-packages/watchdog/observers/inotify_c.py", line 406, in _raise_error
    raise OSError(os.strerror(err))
OSError: Permission denied

The above errors happened on Dose 1.2.0 using watchdog 0.8.3. Though watchdog should switch to polling (like tail -F does) instead of crashing, Dose still has to handle exceptions coming from watchdog.

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