Skip to content

Commit dd9ca52

Browse files
committed
Merge PR #348 into 14.0
Signed-off-by dreispt
2 parents d784026 + 4f9816b commit dd9ca52

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

queue_job/job.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import uuid
1010
from datetime import datetime, timedelta
11+
from random import randint
1112

1213
import odoo
1314

@@ -694,6 +695,8 @@ def _get_retry_seconds(self, seconds=None):
694695
break
695696
elif not seconds:
696697
seconds = RETRY_INTERVAL
698+
if isinstance(seconds, (list, tuple)):
699+
seconds = randint(seconds[0], seconds[1])
697700
return seconds
698701

699702
def postpone(self, result=None, seconds=None):

queue_job/models/queue_job_function.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ def _default_channel(self):
6060
compute="_compute_edit_retry_pattern",
6161
inverse="_inverse_edit_retry_pattern",
6262
help="Pattern expressing from the count of retries on retryable errors,"
63-
" the number of of seconds to postpone the next execution.\n"
63+
" the number of of seconds to postpone the next execution. Setting the "
64+
"number of seconds to a 2-element tuple or list will randomize the "
65+
"retry interval between the 2 values.\n"
6466
"Example: {1: 10, 5: 20, 10: 30, 15: 300}.\n"
67+
"Example: {1: (1, 10), 5: (11, 20), 10: (21, 30), 15: (100, 300)}.\n"
6568
"See the module description for details.",
6669
)
6770
related_action = JobSerialized(string="Related Action (serialized)", base_type=dict)

0 commit comments

Comments
 (0)