11import time
2+ import itertools
23from typing import List , Union , Optional , Dict , Literal
34from dataclasses import dataclass
45from dataclasses_json import dataclass_json
@@ -178,9 +179,8 @@ def create(self,
178179 id = self ._http_client .post (INSTANCES_ENDPOINT , json = payload ).text
179180
180181 # Wait for instance to enter provisioning state with timeout
181- interval = min (initial_interval , max_interval )
182182 deadline = time .monotonic () + max_wait_time
183- while True :
183+ for i in itertools . count () :
184184 instance = self .get_by_id (id )
185185 if instance .status != InstanceStatus .ORDERED :
186186 return instance
@@ -190,8 +190,8 @@ def create(self,
190190 raise TimeoutError (
191191 f"Instance { id } did not enter provisioning state within { max_wait_time :.1f} seconds" )
192192
193- time . sleep ( min (interval , deadline - now ) )
194- interval = min (interval * backoff_coefficient , max_interval )
193+ interval = min (initial_interval * backoff_coefficient ** i , max_interval , deadline - now )
194+ time . sleep (interval )
195195
196196 def action (self , id_list : Union [List [str ], str ], action : str , volume_ids : Optional [List [str ]] = None ) -> None :
197197 """Performs an action on one or more instances.
0 commit comments