cco.processor: fix handling of messages returned by create and update actions
This commit is contained in:
parent
f8480b0b4a
commit
3ac1a6c512
1 changed files with 19 additions and 3 deletions
|
@ -18,9 +18,10 @@ def loop(jobname, fct, data, skip=0, limit=None,
|
|||
break
|
||||
for row in data:
|
||||
r = fct(row)
|
||||
result['count'] += 1
|
||||
if r is not None:
|
||||
result[r] += 1
|
||||
#result['count'] += 1
|
||||
#if r is not None:
|
||||
# result[r['info']] += 1
|
||||
update_counters(result, r)
|
||||
if result['count'] % bsize == 0:
|
||||
logger.info('loop %s: %s' % (jobname, result))
|
||||
if action is not None:
|
||||
|
@ -31,3 +32,18 @@ def loop(jobname, fct, data, skip=0, limit=None,
|
|||
action()
|
||||
logger.info('loop %s finished: %s' % (jobname, result))
|
||||
return result
|
||||
|
||||
def update_counters(result, msg):
|
||||
result['count'] += 1
|
||||
if msg is None:
|
||||
return
|
||||
if isinstance(msg, dict):
|
||||
info = msg.get('info')
|
||||
if info == 'error':
|
||||
result['error'] += 1
|
||||
return
|
||||
key = msg['action'] + 'd'
|
||||
if key in result:
|
||||
result[key] += 1
|
||||
else:
|
||||
result[msg] += 1
|
||||
|
|
Loading…
Add table
Reference in a new issue