splunk-sdk-python
splunk-sdk-python copied to clipboard
fix: stream records lazily in write_records and _execute_chunk_v2
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.
Whoops, my bad. Reverting
@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.