You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by hx...@apache.org on 2022/03/07 02:57:30 UTC

[flink] branch release-1.13 updated: [FLINK-20633][python] Add retry times to download avro

This is an automated email from the ASF dual-hosted git repository.

hxb pushed a commit to branch release-1.13
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.13 by this push:
     new f754870  [FLINK-20633][python] Add retry times to download avro
f754870 is described below

commit f7548702c8f33f1e7c14853ac9a07c1eb5d01929
Author: huangxingbo <hx...@gmail.com>
AuthorDate: Wed Mar 2 11:01:57 2022 +0800

    [FLINK-20633][python] Add retry times to download avro
    
    This closes #18954.
---
 flink-python/pyflink/pyflink_gateway_server.py | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/flink-python/pyflink/pyflink_gateway_server.py b/flink-python/pyflink/pyflink_gateway_server.py
index dd82dc1..a6b8928 100644
--- a/flink-python/pyflink/pyflink_gateway_server.py
+++ b/flink-python/pyflink/pyflink_gateway_server.py
@@ -24,9 +24,10 @@ import re
 import signal
 import socket
 import sys
+import time
 from collections import namedtuple
 from string import Template
-from subprocess import Popen, PIPE, check_output
+from subprocess import Popen, PIPE, check_output, CalledProcessError
 
 from pyflink.find_flink_home import _find_flink_home, _find_flink_source_root
 
@@ -288,7 +289,25 @@ def launch_gateway_server_process(env, args):
         classpath = os.pathsep.join(
             [construct_flink_classpath(env), construct_hadoop_classpath(env)])
         if "FLINK_TESTING" in env:
-            download_apache_avro()
+            total_retry_times = 3
+            retry_times = 0
+            status = 0
+            error = None
+            while retry_times < total_retry_times and not status:
+                retry_times += 1
+                try:
+                    download_apache_avro()
+                    status = 1
+                except CalledProcessError as e:
+                    status = 0
+                    error = e
+                    print("{0} retry download, {1} retries remaining".format(
+                        retry_times, total_retry_times - retry_times))
+                    # sleep 3 seconds and then re-download.
+                    time.sleep(3)
+            if retry_times == total_retry_times and not status:
+                raise error
+
             classpath = os.pathsep.join([classpath, construct_test_classpath()])
         command = [java_executable, jvm_args, jvm_opts] + log_settings \
             + ["-cp", classpath, program_args.main_class] + program_args.other_args