diff --git a/align_data/common/alignment_dataset.py b/align_data/common/alignment_dataset.py index 06da73d..91db5ac 100644 --- a/align_data/common/alignment_dataset.py +++ b/align_data/common/alignment_dataset.py @@ -109,9 +109,9 @@ def commit() -> bool: session.rollback() return False - with make_session() as session: - items = iter(entries) - while batch := tuple(islice(items, self.batch_size)): + items = iter(entries) + while batch := tuple(islice(items, self.batch_size)): + with make_session() as session: self._add_batch(session, batch) # there might be duplicates in the batch, so if they cause # an exception, try to commit them one by one