Fix: Always clean up INotify (#9359)

This commit is contained in:
Trenton H 2025-03-11 10:01:00 -07:00 committed by GitHub
parent 169aa8c8bd
commit f4413e0a08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -294,9 +294,9 @@ class Command(BaseCommand):
inotify = INotify()
inotify_flags = flags.CLOSE_WRITE | flags.MOVED_TO | flags.MODIFY
if recursive:
descriptor = inotify.add_watch_recursive(directory, inotify_flags)
inotify.add_watch_recursive(directory, inotify_flags)
else:
descriptor = inotify.add_watch(directory, inotify_flags)
inotify.add_watch(directory, inotify_flags)
inotify_debounce_secs: Final[float] = settings.CONSUMER_INOTIFY_DELAY
inotify_debounce_ms: Final[int] = inotify_debounce_secs * 1000
@ -305,6 +305,7 @@ class Command(BaseCommand):
notified_files = {}
try:
while not finished:
try:
for event in inotify.read(timeout=timeout_ms):
@ -354,6 +355,5 @@ class Command(BaseCommand):
except KeyboardInterrupt:
logger.info("Received SIGINT, stopping inotify")
finished = True
inotify.rm_watch(descriptor)
finally:
inotify.close()