Corrects the timeout's interaction with files waiting to be consumed

This commit is contained in:
Trenton Holmes 2022-08-09 18:20:47 -07:00
parent 86358d5561
commit ad1f5ae081
2 changed files with 10 additions and 2 deletions

View File

@ -248,7 +248,7 @@ class Command(BaseCommand):
while not finished: while not finished:
try: try:
for event in inotify.read(timeout): for event in inotify.read(timeout=timeout):
if recursive: if recursive:
path = inotify.get_path(event.wd) path = inotify.get_path(event.wd)
else: else:
@ -281,6 +281,15 @@ class Command(BaseCommand):
# These files are still waiting to hit the timeout # These files are still waiting to hit the timeout
notified_files = still_waiting notified_files = still_waiting
# If files are waiting, need to exit read() to check them
# Otherwise, go back to infinite sleep time, but only if not testing
if len(notified_files) > 0:
timeout = inotify_debounce
elif is_testing:
timeout = self.testing_timeout_ms
else:
timeout = None
if self.stop_flag.is_set(): if self.stop_flag.is_set():
logger.debug("Finishing because event is set") logger.debug("Finishing because event is set")
finished = True finished = True

View File

@ -2,7 +2,6 @@ import filecmp
import os import os
import shutil import shutil
from threading import Thread from threading import Thread
from time import monotonic
from time import sleep from time import sleep
from unittest import mock from unittest import mock