MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / retry

Function retry

examples/couchbase/management/collectionmgmt.py:12–21  ·  view source on GitHub ↗
(func, *args, back_off=0.5, limit=5, **kwargs)

Source from the content-addressed store, hash-verified

10
11
12def retry(func, *args, back_off=0.5, limit=5, **kwargs):
13 for i in range(limit):
14 try:
15 return func(*args, **kwargs)
16 except Exception:
17 print("Retry in {} seconds...".format((i + 1) * back_off))
18 time.sleep((i + 1) * back_off)
19
20 raise Exception(
21 "Unable to successfully receive result from {}".format(func))
22
23
24def get_scope(collection_mgr, scope_name):

Callers 1

collectionmgmt.pyFile · 0.70

Calls 1

sleepMethod · 0.45

Tested by

no test coverage detected