Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support graceful at config.ONCE level #144

Open
gigatesseract opened this issue Sep 30, 2024 · 2 comments
Open

Support graceful at config.ONCE level #144

gigatesseract opened this issue Sep 30, 2024 · 2 comments

Comments

@gigatesseract
Copy link

I am writing a django app with celery once and if a task is already queued, I dont want to raise an exception, so I want to add graceful option to the task.

Now, I want that config for all the tasks that I have written, so that I dont have to specify that config evertytime.

From the code,

once_graceful = once_options.get(
            'graceful', self.once.get('graceful', False))

So I can override this in the following places -
* At the apply_async call level
* When I am defining the once property for my task

The problems I think will arise with respect to maintenance -
* I have to do that for all the tasks I have coded
* Since I will have to override the entire once object, in the future, if any defaults are added by the package maintainers, it will be overwritten.

I want to override it at the config.ONCE level so that I can just add it to the app.

I was looking at timeout, and I see something like this-

        once_timeout = once_options.get(
            'timeout', self.once.get('timeout', self.default_timeout))


    @property
    def once_config(self):
        return self.config.ONCE

    @property
    def default_timeout(self):
        return self.once_config['settings'].get('default_timeout', 60 * 60)

So, what I want to do is something like

in the app, have a property for graceful

    @property
    def graceful(self):
        return self.once_config['settings'].get('graceful', False)

Then overwrite it during apply_Async from the property as default. This will help anyone override the graceful config at app level

Let me know yuour thoughts

@gigatesseract
Copy link
Author

I was about to raise a PR, but I realised its one day remaining for Hacktoberfest!
Just wondering if you guys do hacktoberfest?

@rbarbadillo
Copy link

Hey Praveen, not sure if this project is being maintained #134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants