procrastinate-org / procrastinate

PostgreSQL-based Task Queue for Python
https://procrastinate.readthedocs.io/
MIT License
791 stars 51 forks source link

Allow to change the priority when retrying #1096

Open medihack opened 3 days ago

medihack commented 3 days ago

A nice additional feature would be to change the priority when retrying a job. For example, I would like to slightly increase the priority when a job fails and will be retried. Maybe we could use an additional parameter like RetryStrategy(change_priority=2) to increase it by 2.

ewjoachim commented 3 days ago

It makes sense!

I'm not sure about the API you suggested: change is implying add and it's a bit weird.

What about either RetryStrategy(priority_increment=2) Or RetryStrategy(update_priority=lambda attempts: 5+2*attempts) ?

medihack commented 21 hours ago

Yes, I really like the lambda usage. How about RetryStrategy(update_priority=lambda job: 5+2*job.attempts)? With access to the job, it's even possible to get the current priority.

ewjoachim commented 16 hours ago

Ok !