splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

fix: stream records lazily in write_records and _execute_chunk_v2

Open shivamsharma2106 opened this issue 6 months ago • 2 comments

Problem: _execute_chunk_v2 was accumulating all records into a list before writing them, causing OOM (out-of-memory) errors when generating commands produced large result sets. Similarly, write_records was materializing the full iterator into a list upfront.

Fix:

  • In _execute_chunk_v2: write each record immediately as it is generated instead of buffering all records first.
  • In write_records: return early if records is NotImplemented instead of materializing into an empty list.

This makes both methods stream records lazily, avoiding unnecessary memory allocation.

shivamsharma2106 avatar May 29 '26 15:05 shivamsharma2106

Whoops, my bad. Reverting

Ickerday avatar Jun 09 '26 13:06 Ickerday

@shivamsharma2106 could I ask you to have a look at #804 and try it out? It's a dirty workaround, but getting rid of list() here breaks current functionality.

Ickerday avatar Jun 09 '26 13:06 Ickerday