Skip to content

Commit

Permalink
[FLINK-17092][python] Add retry when pip install dependencies (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
shuiqiangchen authored and dianfu committed May 8, 2020
1 parent 92f1ce7 commit 62c0589
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions flink-python/pyflink/fn_execution/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,24 @@ def pip_install_requirements():
if requirements_cache_path is not None:
pip_install_commands.extend(["--find-links", requirements_cache_path])

logging.info("Run command: %s\n" % " ".join(pip_install_commands))
exit_code = call(
pip_install_commands, stdout=sys.stdout, stderr=sys.stderr, env=env)
if exit_code > 0:
raise Exception(
"Run command: %s error! exit code: %d" %
(" ".join(pip_install_commands), exit_code))

max_retry_times = 3
cur_retry = 0
while cur_retry < max_retry_times:
cur_retry += 1
logging.info("Run command: %s with retry (%d/%d)\n" % (" ".join(pip_install_commands),
cur_retry, max_retry_times))
exit_code = call(
pip_install_commands, stdout=sys.stdout, stderr=sys.stderr, env=env)
if exit_code != 0:
if cur_retry < max_retry_times:
logging.error("Run command: %s error! exit code: %d. Retry to run again!" %
(" ".join(pip_install_commands), exit_code))
else:
raise Exception(
"Run command: %s error! exit code: %d. Max retry times exhausted!" %
(" ".join(pip_install_commands), exit_code))
else:
break
os.environ["PYTHONPATH"] = env["PYTHONPATH"]
os.environ["PATH"] = env["PATH"]

Expand Down

0 comments on commit 62c0589

Please sign in to comment.