PyInotify icon indicating copy to clipboard operation
PyInotify copied to clipboard

AttributeError: 'Inotify' object has no attribute '_Inotify__inotify_fd'

Open to7m opened this issue 4 years ago • 1 comments

OS: Arch Linux Python version: 3.9.1

Originally noticed here: https://github.com/dsoprea/PyInotify/issues/90, and now I can reproduce it.

The AttributeError keeps popping up, for example in del:

File "/home/to7m/.local/lib/python3.9/site-packages/inotify/adapters.py", line 79, in __del__
    os.close(self.__inotify_fd)
AttributeError: 'Inotify' object has no attribute '_Inotify__inotify_fd'

On my system, the following code reproduces the problem consistently:

from multiprocessing import Process
from inotify.adapters import Inotify
from time import sleep


def proc():
    inotify_obj = Inotify()
    sleep(60)


process_count = 1000
for _ in range(process_count):
    Process(target=proc).start()

It may be necessary to increase process_count on other systems to expose the bug.

to7m avatar Apr 08 '21 18:04 to7m

Related: As other issue reports suggest, I think a context manager might help in general.

to7m avatar Apr 10 '21 23:04 to7m