Skip to content

Commit ce24f0c

Browse files
perf(functions): Use exponential instead of constant backoff for FunctionCall:wait (#2312)
1 parent 9524fcd commit ce24f0c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cognite/client/data_classes/functions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
WriteableCogniteResourceList,
1818
)
1919
from cognite.client.data_classes.shared import TimestampRange
20+
from cognite.client.utils._retry import Backoff
2021
from cognite.client.utils._time import ms_to_datetime
2122

2223
if TYPE_CHECKING:
@@ -685,9 +686,10 @@ def _get_identifiers_or_raise(call_id: int | None, function_id: int | None) -> t
685686
return call_id, function_id
686687

687688
def wait(self) -> None:
689+
backoff = Backoff(max_wait=5, base=1)
688690
while self.status == "Running":
689691
self.update()
690-
time.sleep(1.0)
692+
time.sleep(next(backoff))
691693

692694

693695
class FunctionCallList(CogniteResourceList[FunctionCall], InternalIdTransformerMixin):

0 commit comments

Comments
 (0)