Skip to content

Commit 0b63d12

Browse files
authored
Merge pull request #111 from Skrattoune/patch-8
Delegating set_parent_task to ProcessInfo.__init__
2 parents c5a741e + 9b6fd7f commit 0b63d12

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

huey_monitor/tqdm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ def __init__(self,
6868
cumulate_progress=cumulate2parents,
6969
)
7070

71+
if parent_task_id:
72+
TaskModel.objects.set_parent_task(
73+
main_task_id=parent_task_id,
74+
sub_task_id=task.id,
75+
)
76+
7177
self.total_progress = 0
7278

7379
logger.info('Init TaskModel %s', self)

huey_monitor_tests/test_app/tasks.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,10 @@ def parallel_sub_task(task, parent_task_id, item_chunk, **info_kwargs):
8787
"""
8888
Useless example: Just calculate the SHA256 hash from all files
8989
"""
90-
# Save relationship between the main and sub tasks:
91-
TaskModel.objects.set_parent_task(
92-
main_task_id=parent_task_id,
93-
sub_task_id=task.id
94-
)
95-
9690
total_items = len(item_chunk)
9791

98-
# Init progress information of this sub task:
92+
# Init progress information of this sub task
93+
# and save relationship between the main and sub tasks:
9994
process_info = ProcessInfo(
10095
task, total=total_items, parent_task_id=parent_task_id, **info_kwargs
10196
)

0 commit comments

Comments
 (0)