Skip to content

Commit 0097ea1

Browse files
limit automatic records batch size to 2000
1 parent 77c47e3 commit 0097ea1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

janrain_datalib/schemarecords.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ def create_batch(batch):
7171
if not batch_size:
7272
# find reasonable batch size based on size of first record
7373
record_len = len(json.dumps(record))
74-
# batches will be approx 1MB
74+
# limit batches to approx 1MB
7575
batch_size = 1 + int(1000000 / record_len)
76+
if batch_size > 2000:
77+
# or 2000 records, whichever is less
78+
batch_size = 2000
7679
if len(batch) >= batch_size:
7780
for item in create_batch(batch):
7881
yield item

0 commit comments

Comments
 (0)