@@ -767,7 +767,7 @@ def __getitem__(self, index):
767767 def _open_file (self ):
768768 """Open the configured file for processing"""
769769 file_opened = False
770- while not self .stop_reading . is_set () and not self . stop_reading_proc . is_set ():
770+ while not self ._is_stop_reading_set ():
771771 if dltlib .dlt_file_open (ctypes .byref (self ), self .filename , self .verbose ) >= DLT_RETURN_OK :
772772 file_opened = True
773773 break
@@ -791,6 +791,9 @@ def _log_message_progress(self):
791791 self .msg .ctid ,
792792 )
793793
794+ def _is_stop_reading_set (self ):
795+ return self .stop_reading .is_set () or self .stop_reading_proc .is_set ()
796+
794797 def __iter__ (self ): # pylint: disable=too-many-branches
795798 """Iterate over messages in the file"""
796799 logger .debug ("Starting File Read" )
@@ -804,17 +807,17 @@ def __iter__(self): # pylint: disable=too-many-branches
804807 self ._open_file ()
805808
806809 found_data = False
807- while (
808- not self .stop_reading .is_set () and not self .stop_reading_proc .is_set ()
809- ) or corruption_check_try : # pylint: disable=too-many-nested-blocks
810+ while not self ._is_stop_reading_set () or corruption_check_try : # pylint: disable=too-many-nested-blocks
810811 os_stat = os .stat (self .filename )
811812 mtime = os_stat .st_mtime
812813
813814 if mtime != cached_mtime and os_stat .st_size or corruption_check_try :
814815 cached_mtime = mtime
815816 corruption_check_try = False
816817
817- while dltlib .dlt_file_read (ctypes .byref (self ), self .verbose ) >= DLT_RETURN_OK :
818+ while not self ._is_stop_reading_set () and (
819+ dltlib .dlt_file_read (ctypes .byref (self ), self .verbose ) >= DLT_RETURN_OK
820+ ):
818821 found_data = True
819822 if (
820823 self .filter
0 commit comments