Skip to content

Commit

Permalink
Merge pull request #202 from keitaroinc/parametrize-job-config
Browse files Browse the repository at this point in the history
Read chunk size, chunk inserts and timeouts from config
  • Loading branch information
amercader committed Sep 29, 2020
2 parents 45be714 + 5986df1 commit d76f5f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions datapusher/jobs.py
Expand Up @@ -30,8 +30,9 @@
locale.setlocale(locale.LC_ALL, '')

MAX_CONTENT_LENGTH = web.app.config.get('MAX_CONTENT_LENGTH') or 10485760
CHUNK_SIZE = 16 * 1024 # 16kb
DOWNLOAD_TIMEOUT = 30
CHUNK_SIZE = web.app.config.get('CHUNK_SIZE') or 16384
CHUNK_INSERT_ROWS = web.app.config.get('CHUNK_INSERT_ROWS') or 250
DOWNLOAD_TIMEOUT = web.app.config.get('DOWNLOAD_TIMEOUT') or 30

if web.app.config.get('SSL_VERIFY') in ['False', 'FALSE', '0', False, 0]:
SSL_VERIFY = False
Expand Down Expand Up @@ -503,7 +504,7 @@ def row_iterator():
return headers_dicts, result

count = 0
for i, chunk in enumerate(chunky(result, 250)):
for i, chunk in enumerate(chunky(result, CHUNK_INSERT_ROWS)):
records, is_it_the_last_chunk = chunk
count += len(records)
logger.info('Saving chunk {number} {is_last}'.format(
Expand Down

0 comments on commit d76f5f8

Please sign in to comment.