Working with custom Task types #163
Unanswered
joeyjurjens
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm wondering if there's a "correct" way of creating your own Task types that add additional functionalities.
I've created my own
Task
type:But it's not as easy as it seemed when I read the DEP.
I need to create a custom decorator, because it only accepts the
priority, queue_name, backend, enqueue_on_commit
arguments.I then wrote some tests to check whether my decorator worked, and added override_settings above to TestClass to use my custom backend but because the task decorator is executed immediately this would get the wrong Task class (because the import is above the TestCase). So I had to run the tests with a pre-defined TASK setting, which is fine but I wonder if this is intentional? Shouldn't the task class be created after django is fully started?
I wonder if there has been any thoughts about having Task types that add extra functionality and if there are best practices for this.
Maybe the decorator could take args & kwargs so that potential Task types could actually handle this.
Nevertheless, I got it working fine but was just wondering if there is a "correct" way of doing so.
Beta Was this translation helpful? Give feedback.
All reactions