boxine / django-huey-monitor

Django based tool for monitoring huey task queue: https://github.com/coleifer/huey
GNU General Public License v3.0
86 stars 20 forks source link

Delegating set_parent_task to ProcessInfo.__init__ #111

Closed Skrattoune closed 1 year ago

Skrattoune commented 1 year ago

Hi Jedie,

working a bit on the subtasks, I realized that currently, we have to link to parent_task_id two times: first through the task code through the manager:

            main_task_id=parent_task_id,
            sub_task_id=task.id,
        )

and second, we have to feed ProcessInfo with parent_task_id

I initially thought that within ProcessInfo.__init__ we should read parent_task_id from the task.

Then I realized that, as ProcessInfo.__init__ is anyway used to update fields from TaskModel, it should be better to keep the same logic, and allow ProcessInfo.__init__ to generate the link between parent_task and sub_task if parent_task_id is provided.

That way, we gain a step, and the process of creating sub tasks is much easier (especially for new users).

And all previous implementations are still working the same (we just update the link between parent and sub task for nothing)

jedie commented 1 year ago

Thanks!