lordgamez commented on a change in pull request #1076:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1076#discussion_r648049587



##########
File path: docker/test/integration/minifi/core/FileSystemObserver.py
##########
@@ -31,16 +31,21 @@ def restart_observer_if_needed(self):
         self.observer.schedule(self.event_handler, self.test_output_dir, 
recursive=True)
         self.observer.start()
 
-    def wait_for_output(self, timeout_seconds, output_validator, max_files):
+    def wait_for_output(self, timeout_seconds, max_files):
         logging.info('Waiting up to %d seconds for %d test outputs...', 
timeout_seconds, max_files)
         self.restart_observer_if_needed()
+        if max_files <= self.event_handler.get_num_files_created():
+            return
         wait_start_time = time.perf_counter()
-        for i in range(0, max_files):
+        for _ in range(0, max_files):
             # Note: The timing on Event.wait() is inaccurate
-            self.done_event.wait(timeout_seconds)
-            self.done_event.clear()
-            current_time = time.perf_counter()
-            if timeout_seconds < (current_time - wait_start_time) or 
output_validator.validate():
+            self.done_event.wait(timeout_seconds - time.perf_counter() + 
wait_start_time)

Review comment:
       I'm not sure about this. Could you elaborate what do you mean by 
increments here? It seems to me that we are only waiting until a certain time 
point, the end of the timeout calculated from the start time of the function 
call. We are then waiting for the `done_event` to be set by a newly created 
file, for the number of `max_files` or until the designated time point is 
reached.
   
   The first check is also needed IMO as it could happen that the observer is 
restarted after the required files are already created so we need to check them 
beforehand, because no new files will be created, so the event will not be 
notified by the observer.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to