Skip to content

Commit

Permalink
Ensure tasks complete on exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sbscully committed Aug 23, 2024
1 parent abfc541 commit 8047401
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions opencage/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ async def read_one_line(self, row, row_id):
async def worker(self, output, queue, progress):
while True:
item = await queue.get()
await self.geocode_one_address(output, item['row_id'], item['address'])

if progress:
progress.update(1)
try:
await self.geocode_one_address(output, item['row_id'], item['address'])

queue.task_done()
if progress:
progress.update(1)
except Exception as exc:
traceback.print_exception(exc, file=sys.stderr)
finally:
queue.task_done()

async def geocode_one_address(self, output, row_id, address):
def on_backoff(details):
Expand Down

0 comments on commit 8047401

Please sign in to comment.