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

Crashed in calls.py(32): _check_nonnegative #71

Closed
renatosamperio opened this issue Apr 15, 2019 · 5 comments
Closed

Crashed in calls.py(32): _check_nonnegative #71

renatosamperio opened this issue Apr 15, 2019 · 5 comments

Comments

@renatosamperio
Copy link

renatosamperio commented Apr 15, 2019

I made a simple program to monitor my home path:

import inotify.adapters

def _main():
    i = inotify.adapters.InotifyTree('/opt/test_user/')
    try:
        for event in i.event_gen():
            if event is None:
                continue
            (header, types, path, filename) = event
            if 'IN_ISDIR' not in types:
               print("PATH=[{}] FILENAME=[{}] EVENT_TYPES={}".format(
                 path, filename, types))
if __name__ == '__main__':
    _main()

I am getting the following error:

Traceback (most recent call last):
  File "sample2.py", line 26, in <module>
    _main()
  File "sample2.py", line 4, in _main
    i = inotify.adapters.InotifyTree('/opt/test_user/')
  File "/usr/local/lib/python2.7/dist-packages/inotify/adapters.py", line 340, in __init__
    self.__load_tree(path)
  File "/usr/local/lib/python2.7/dist-packages/inotify/adapters.py", line 354, in __load_tree
    for filename in os.listdir(current_path):

I had to run the program with SUDO though. But whenver I remove the following exception, all works fine:

def _check_nonnegative(result):
    if result == -1:
        raise InotifyError("Call failed (should not be -1): (%d)" % 
                           (result,))

Why was this check required? Is it good idea to remove it?

Regards,

Renato.

@alphadx
Copy link

alphadx commented May 8, 2019

This is an debian/ubuntu "issue". You can fix it adding this line in /etc/sysctl.conf file.
fs.inotify.max_user_watches=524288

It's about the max number of user that can watch. It show when you try to watch a huge number of files/directory.

@rgammans
Copy link

This maybe a seperate issue but....

I've just hit this problem; and got the following message.

inotify.calls.InotifyError: Call failed (should not be -1): (-1) ERRNO=(0)

And was confused, and slowed in my debugging by the zero errno. I changed the sysctl variable as above; and it works; but I still see a zero errno if I try something that shouldn't work. Is there something else going on here? ( I would have expected something like ENOSPC and EACCESS respectively, or at least their numeric equivalents)

Python 3.7.2rc1 (default, Dec 12 2018, 06:25:49)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inotify.adapters
>>> i = inotify.adapters.Inotify()
>>> i.add_watch("./testdir")
1
>>> i.add_watch("/root" )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.local/share/virtualenvs/test/lib/python3.7/site-packages/inotify/adapters.py", line 95, in add_watch
    wd = inotify.calls.inotify_add_watch(self.__inotify_fd, path_bytes, mask)
  File "~/.local/share/virtualenvs/test/lib/python3.7/site-packages/inotify/calls.py", line 36, in _check_nonnegative
    (result,))
inotify.calls.InotifyError: Call failed (should not be -1): (-1) ERRNO=(0)

@dsoprea
Copy link
Owner

dsoprea commented Jul 1, 2019

I'm not really sure where we can go with this discussion. Doesn't seem like an issue with the project. As much as I'd like to help, I don't think I/we can.

If you make any progress, feel free to post a pull request with a modification to the README.md to share it with others.

@alphadx That includes you. You're welcome to add a "Troubleshooting" section with this as the first item.

@dsoprea dsoprea closed this as completed Jul 1, 2019
@prafulchavda4
Copy link

echo fs.inotify.max_user_watches=16384 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

it's work please check it

@prafulchavda4
Copy link

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

5 participants