From 480a37b9f04a43aba10c8db2c63fd497ec2c4415 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 30 May 2022 11:43:47 -0400 Subject: [PATCH] Introduce 10uS delay in Inotify.read_events() to trigger a race --- src/watchdog/observers/inotify_c.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/watchdog/observers/inotify_c.py b/src/watchdog/observers/inotify_c.py index 6161f4f9..88f371b4 100644 --- a/src/watchdog/observers/inotify_c.py +++ b/src/watchdog/observers/inotify_c.py @@ -24,6 +24,7 @@ from functools import reduce from ctypes import c_int, c_char_p, c_uint32 from watchdog.utils import UnsupportedLibc +import time libc = ctypes.CDLL(None) @@ -259,6 +260,8 @@ def read_events(self, event_buffer_size=DEFAULT_EVENT_BUFFER_SIZE): # created subdirectories/files. This will handle # mkdir -p foobar/blah/bar; touch foobar/afile + time.sleep(0.000_01) + def _recursive_simulate(src_path): events = [] for root, dirnames, filenames in os.walk(src_path):