INNER CODE UNIT · Python
flush_access_log_buffer
BlessedRebuS/Krawl · src/database/core.py:451
def flush_access_log_buffer(self, max_rows: int = 50_000) -> int:
"""
Bulk-insert buffered access log entries into the database.
Drains in _FLUSH_BATCH_SIZE statements until empty, so the flush rate
follows arrival rate. max_rows caps the work one run may do.
Returns the number of entries flushed.
"""
total = 0
while total < max_rows:
entries = self._pop_batch(_FLUSH_BATCH_SIZE)
if not entries:
break
inserted = self._insert_access_log_batch(entries)
if inserted == 0:
break # batch failed and was re-queued; stop to avoid spinning
total += inserted