Replies: 2 comments
-
If I understand correctly what you are trying to achieve, I am not sure there is a fully automated way to provide such an API. To summarize, you want to define other tasks using the How does that sound? |
Beta Was this translation helpful? Give feedback.
-
@georgepsarakis Yes - using a reusable base class that implements similar functionality so that we can move to the recommended way of calling tasks I am not visualizing what you mean though. Are you saying to move the logic handled by the Jobtastic base class into a context manager and using the context block as the replacement for the "calculate_result" method? |
Beta Was this translation helpful? Give feedback.
-
I am not sure if this issue is a feature request or a request for guidance. I do not see how this could be accomplished, so I guess it is a feature request -- but perhaps it is already possible?
I am trying to swap from using class based tasks to decorator tasks. Simple tasks are easy to swap over. However, some of my tasks are based around this class based task: https://github.com/PolicyStat/jobtastic/blob/v2.1.1/jobtastic/task.py#L313
The Jobtastic Task Class provides a run method that prevents duplicate tasks from running simultaneously and abstracts some cruft that is pretty handy. Then its run method calls
calculate_result()
to perform the actual work of the task you create.What has been holding this back is since the decorator makes your function the run method, how can I implement this functionality without rewriting it in every task? If the run() method of the Jobtastic Task is overridden, the utility of the task is lost.
Is there a way to incorporate the advanced runtime logic of the Jobtastic Task? Is it possible to tell the decorator what method the wrapped function should become? Or would an additional
run()
wrapper be required to handle this with a decorated approach?Beta Was this translation helpful? Give feedback.
All reactions