Skip to content

Commit

Permalink
fix: fix list add result
Browse files Browse the repository at this point in the history
  • Loading branch information
vTuanpham committed Dec 10, 2023
1 parent 39172ba commit 4220a7a
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions translator/data_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ def callback_list_done(future):
nonlocal translated_list_data
nonlocal finished_task
nonlocal manager
nonlocal lock
if not future.exception():
with lock:
translated_list_data.append(future.result())
finished_task += 1
translated_list_data.extend(future.result())
finished_task += 1
else:
tqdm.write(f"Sub task of chunk {progress_idx} with field {field_name} failed with the following error: {future.exception()}."
f"\nRestarting thread when others finished...")
Expand Down Expand Up @@ -316,14 +314,12 @@ def translate_converted(self,
def callback_done(future):
nonlocal translated_data
nonlocal finished_task
nonlocal lock
nonlocal progress_bar
if not future.exception():
with lock:
translated_data += future.result()
finished_task += 1
progress_bar.update(1)
tqdm.write("\nTask finished, adding translated data to result...\n")
translated_data.extend(future.result())
finished_task += 1
progress_bar.update(1)
tqdm.write("\nTask finished, adding translated data to result...\n")
else:
tqdm.write(f"\nTask failed with the following error: {future.exception()}."
f"\nRestarting thread when others finished\n")
Expand Down

0 comments on commit 4220a7a

Please sign in to comment.