aosabook/500lines · error · OSError
inotify_init() error: {}
Error message
inotify_init() error: {} What it means
Error "inotify_init() error: {}" thrown in aosabook/500lines.
Source
Thrown at contingent/code/contingent/io.py:41
# offer inotify_wait, and fall back to looping_wait_on().
_setup_libc()
return inotify_wait_on(paths)
def looping_wait_on(paths):
start = time.time()
changed_paths = []
while not changed_paths:
time.sleep(0.5)
changed_paths = [path for path in paths
if os.stat(path).st_mtime > start]
return changed_paths
def inotify_wait_on(paths):
paths = [path.encode('ascii') for path in paths]
fd = _libc.inotify_init()
descriptors = {}
if fd == -1:
raise OSError('inotify_init() error: {}'.format(
os.strerror(ctypes.get_errno())))
try:
for path in paths:
rv = _libc.inotify_add_watch(fd, path, 0x2)
if rv == -1:
raise OSError('inotify_add_watch() error: {}'.format(
os.strerror(ctypes.get_errno())))
descriptors[rv] = path
buf = os.read(fd, 1024)
# TODO: continue with some more reads with 0.1 second timeouts
# to empty the list of roughly-simultaneous events before
# closing our file descriptor and returning?
finally:
pass #os.close(fd)
time.sleep(0.1) # until above TODO is done
wd, mask, cookie, name_length = struct.unpack('iIII', buf)
return [descriptors[wd].decode('ascii')]
View on GitHub (pinned to fba689d101)
Solutions
- Run on a Linux kernel with inotify support; on other platforms use the polling fallback wait_on instead of inotify_wait_on.
- Raise the per-process file descriptor limit (ulimit -n) if inotify_init fails with EMFILE.
- Check /proc/sys/fs/inotify/max_user_instances and increase it if the instance limit is reached.
Example fix
sysctl fs.inotify.max_user_instances=512 # or catch OSError and fall back to wait_on(paths)
When it happens
Trigger: Thrown at contingent/code/contingent/io.py:41 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of aosabook/500lines@fba689d101 (2026-08-13).
Data as JSON: /api/errors/8fb3e20113284f5c.
Report an issue: GitHub.