Skip to content

Commit afb8bc2

Browse files
authored
invoke: add configurable number of retries (#86)
1 parent 269933e commit afb8bc2

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ running [Faasm](https://github.com/faasm/faasm) cluster.
88
To install `faasmctl` you need a working `pip` (virtual-)environment. Then:
99

1010
```bash
11-
pip install faasmctl==0.43.0
11+
pip install faasmctl==0.44.0
1212
```
1313

1414
## Usage

faasmctl/util/invoke.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def invoke_wasm(
1919
dict_out=False,
2020
ini_file=None,
2121
host_list=None,
22+
num_retries=30,
2223
):
2324
"""
2425
Main entrypoint to invoke an arbitrary message in a Faasm cluster
@@ -86,15 +87,15 @@ def invoke_wasm(
8687
)
8788
raise RuntimeError("Error preloading scheduling decision!")
8889

89-
result = invoke_and_await(url, msg, expected_num_messages)
90+
result = invoke_and_await(url, msg, expected_num_messages, num_retries)
9091

9192
if dict_out:
9293
return MessageToDict(result)
9394

9495
return result
9596

9697

97-
def invoke_and_await(url, json_msg, expected_num_messages):
98+
def invoke_and_await(url, json_msg, expected_num_messages, num_retries):
9899
"""
99100
Invoke the given JSON message to the given URL and poll the planner to
100101
wait for the response
@@ -106,10 +107,11 @@ def invoke_and_await(url, json_msg, expected_num_messages):
106107
# tolerate this a number of times (for example, to accomodate for dynamic
107108
# cluster sizes)
108109

109-
num_retries = 10
110-
sleep_period_secs = 0.5
110+
sleep_period_secs = 1.5
111111

112-
for i in range(num_retries):
112+
i = 0
113+
while i < num_retries:
114+
i += 1
113115
response = post(url, data=json_msg, timeout=None)
114116
if response.status_code == 500 and response.text == "No available hosts":
115117
print("No available hosts, retrying... {}/{}".format(i + 1, num_retries))

faasmctl/util/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FAASMCTL_VERSION = "0.43.0"
1+
FAASMCTL_VERSION = "0.44.0"
22

33

44
def get_version():

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "faasmctl"
7-
version = "0.43.0"
7+
version = "0.44.0"
88
authors = [
99
{ name="Faasm Team", email="[email protected]" },
1010
]

0 commit comments

Comments
 (0)