@@ -155,10 +155,12 @@ def _parse_retry_pattern(self):
155155 try :
156156 # as json can't have integers as keys and the field is stored
157157 # as json, convert back to int
158- retry_pattern = {
159- int (try_count ): postpone_seconds
160- for try_count , postpone_seconds in self .retry_pattern .items ()
161- }
158+ retry_pattern = {}
159+ for try_count , postpone_value in self .retry_pattern .items ():
160+ if isinstance (postpone_value , int ):
161+ retry_pattern [int (try_count )] = postpone_value
162+ else :
163+ retry_pattern [int (try_count )] = tuple (postpone_value )
162164 except ValueError :
163165 _logger .error (
164166 "Invalid retry pattern for job function %s,"
@@ -187,8 +189,9 @@ def job_config(self, name):
187189 def _retry_pattern_format_error_message (self ):
188190 return _ (
189191 "Unexpected format of Retry Pattern for {}.\n "
190- "Example of valid format:\n "
191- "{{1: 300, 5: 600, 10: 1200, 15: 3000}}"
192+ "Example of valid formats:\n "
193+ "{{1: 300, 5: 600, 10: 1200, 15: 3000}}\n "
194+ "{{1: (1, 10), 5: (11, 20), 10: (21, 30), 15: (100, 300)}}"
192195 ).format (self .name )
193196
194197 @api .constrains ("retry_pattern" )
@@ -201,12 +204,20 @@ def _check_retry_pattern(self):
201204 all_values = list (retry_pattern ) + list (retry_pattern .values ())
202205 for value in all_values :
203206 try :
204- int (value )
207+ self . _retry_value_type_check (value )
205208 except ValueError as ex :
206209 raise exceptions .UserError (
207210 record ._retry_pattern_format_error_message ()
208211 ) from ex
209212
213+ def _retry_value_type_check (self , value ):
214+ if isinstance (value , (tuple , list )):
215+ if len (value ) != 2 :
216+ raise ValueError
217+ [self ._retry_value_type_check (element ) for element in value ]
218+ return
219+ int (value )
220+
210221 def _related_action_format_error_message (self ):
211222 return _ (
212223 "Unexpected format of Related Action for {}.\n "
0 commit comments