Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 835
luistm Avatar asked Oct 23 '25 18:10

luistm


1 Answers

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.

like image 112
Simeon Visser Avatar answered Oct 26 '25 08:10

Simeon Visser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!