[dataio/nix] adding sleep while writing

This commit is contained in:
wendtalexander 2024-10-21 10:28:25 +02:00
parent 6d2eb09c65
commit 33f046c072

View File

@ -1,3 +1,4 @@
import time
from IPython import embed from IPython import embed
import nixio import nixio
@ -17,15 +18,21 @@ class NixWriter:
chunk = 1000 chunk = 1000
log.debug("Starting the writing") log.debug("Starting the writing")
self.write = True self.write = True
total_count = self.buffer.totalcount()
while self.write: while self.write:
# log.debug(items) if total_count - items >= chunk:
try: log.debug(items)
data, _ = self.buffer.read(items, extend=chunk) try:
self.data_array.append(data) data, _ = self.buffer.read(items, extend=chunk)
except IndexError as e: self.data_array.append(data)
# log.debug(f"{e}") except IndexError as e:
time.sleep(0.01)
log.debug(f"{e}")
items += chunk
else:
time.sleep(0.01)
continue continue
items += chunk
log.debug("Stoppint the writing") log.debug("Stoppint the writing")
log.debug(f"Samples written {items}") log.debug(f"Samples written {items}")
self.nix_file.close() self.nix_file.close()