Skip to content

Commit

Permalink
feat: add an option to clean dlt read buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
birnevogel11 committed Feb 12, 2024
1 parent 23b429d commit 6e36026
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dlt/dlt.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,14 @@ def __init__(self, **kwords):
self.indexed = False
self.end = False
self.live_run = kwords.pop("is_live", False)

# Stop event for threading usage in caller
self.stop_reading = threading.Event()
# Stop event for process usage in caller
self.stop_reading_proc = multiprocessing.Event()

self.stop_reading_clean_buffer = False

def __repr__(self):
# pylint: disable=bad-continuation
return "<DLTFile object {} with {} messages>".format(
Expand Down Expand Up @@ -818,9 +821,10 @@ def __iter__(self): # pylint: disable=too-many-branches
cached_mtime = mtime
corruption_check_try = False

while not (self.stop_reading.is_set() or self.stop_reading_proc.is_set()) and (
dltlib.dlt_file_read(ctypes.byref(self), self.verbose) >= DLT_RETURN_OK
):
while not (
not self.stop_reading_clean_buffer
and (self.stop_reading.is_set() or self.stop_reading_proc.is_set())
) and (dltlib.dlt_file_read(ctypes.byref(self), self.verbose) >= DLT_RETURN_OK):
found_data = True
if (
self.filter
Expand Down

0 comments on commit 6e36026

Please # to comment.