test-my-pr: Retry if failed to get package (#2515)
This commit is contained in:
parent
bbfd10a69f
commit
0d361f8a2e
|
@ -160,10 +160,6 @@ while True:
|
|||
package = package_url
|
||||
else:
|
||||
package = get_package(server_address)
|
||||
while len(package) == 0:
|
||||
print("network or server might be temporarily down.. will try again in 30 seconds..")
|
||||
time.sleep(30)
|
||||
package = get_package(server_address)
|
||||
tgz = download_package(work_path, package, bandwidth_limit)
|
||||
if tgz is None:
|
||||
print("No package downloaded")
|
||||
|
|
|
@ -135,10 +135,11 @@ def get_packages_count(server_address):
|
|||
|
||||
|
||||
def get_package(server_address, package_index=None):
|
||||
print('Connecting to server to get assigned work..')
|
||||
package = b''
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
while not package:
|
||||
print('Connecting to server to get assigned work..')
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
sock.connect(server_address)
|
||||
if package_index is None:
|
||||
sock.send(b'get\n')
|
||||
|
@ -147,8 +148,8 @@ def get_package(server_address, package_index=None):
|
|||
sock.send(request.encode())
|
||||
package = sock.recv(256)
|
||||
except socket.error:
|
||||
pass
|
||||
sock.close()
|
||||
print("network or server might be temporarily down.. will try again in 30 seconds..")
|
||||
time.sleep(30)
|
||||
return package.decode('utf-8')
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import argparse
|
|||
import os
|
||||
import sys
|
||||
import random
|
||||
import time
|
||||
import subprocess
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -73,9 +72,6 @@ if __name__ == "__main__":
|
|||
|
||||
while packages_processed < args.p and len(packages_idxs) > 0:
|
||||
package = lib.get_package(lib.server_address, packages_idxs.pop())
|
||||
if len(package) == 0:
|
||||
print("network or server might be temporarily down..")
|
||||
sys.exit(1)
|
||||
|
||||
tgz = lib.download_package(work_path, package, None)
|
||||
if tgz is None:
|
||||
|
|
Loading…
Reference in New Issue