Question

Can i use python os.nice to lower the niceness of a celery task?

I was thinking of something like this:

@task()
def maintenance_requests():
    os.nice(5)
    request = requests.session()
    request.get('http://maintenance/', params={})

Is there any other way of doing this?

Thanks in advance!

EDIT: Since my application is IO bound, i've discovered that ionice was the command i needed. Did some tests, and it works like a charm. Thanks

Était-ce utile?

La solution

I don't think you can specify the niceness of a particular Celery task as niceness is a property of the process. A task is simply some code that runs on a Celery worker.

However you can setup a Celery worker with a lower niceness and route maintanance tasks to that worker using Celery's task routing configuration.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top