Permalink
Browse files

Retry nk_persons api call 5x on error to fix ValueError

It sometimes failes with ValueError: No JSON object could be decoded
  • Loading branch information...
1 parent de89907 commit 91f1fc0a2618cc3646aaf2eceb43dc04cc6a814e @csenger committed Jul 22, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 offenesparlament/transform/persons.py
@@ -58,7 +58,18 @@ def generate_person_long_names(engine):
'slug': slug,
'id': person['id']},
unique=['id'])
- nkp.ensure_value(long_name, data=person)
+ tries = 0
+ while True:
+ try:
+ nkp.ensure_value(long_name, data=person)
+ except ValueError, E:
+ log.warn('Exception: %s' % str(E))
+ tries = tries + 1
+ if tries > 5:
+ raise
+ else:
+ break
+
log.info("Updating 'rollen' to have fingerprints...")
Rolle = sl.get_table(engine, 'rolle')

0 comments on commit 91f1fc0

Please sign in to comment.