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
|
package = package_url
|
||||||
else:
|
else:
|
||||||
package = get_package(server_address)
|
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)
|
tgz = download_package(work_path, package, bandwidth_limit)
|
||||||
if tgz is None:
|
if tgz is None:
|
||||||
print("No package downloaded")
|
print("No package downloaded")
|
||||||
|
|
|
@ -135,20 +135,21 @@ def get_packages_count(server_address):
|
||||||
|
|
||||||
|
|
||||||
def get_package(server_address, package_index=None):
|
def get_package(server_address, package_index=None):
|
||||||
print('Connecting to server to get assigned work..')
|
|
||||||
package = b''
|
package = b''
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
while not package:
|
||||||
try:
|
print('Connecting to server to get assigned work..')
|
||||||
sock.connect(server_address)
|
try:
|
||||||
if package_index is None:
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||||
sock.send(b'get\n')
|
sock.connect(server_address)
|
||||||
else:
|
if package_index is None:
|
||||||
request = 'getPackageIdx:' + str(package_index) + '\n'
|
sock.send(b'get\n')
|
||||||
sock.send(request.encode())
|
else:
|
||||||
package = sock.recv(256)
|
request = 'getPackageIdx:' + str(package_index) + '\n'
|
||||||
except socket.error:
|
sock.send(request.encode())
|
||||||
pass
|
package = sock.recv(256)
|
||||||
sock.close()
|
except socket.error:
|
||||||
|
print("network or server might be temporarily down.. will try again in 30 seconds..")
|
||||||
|
time.sleep(30)
|
||||||
return package.decode('utf-8')
|
return package.decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import random
|
import random
|
||||||
import time
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -73,9 +72,6 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
while packages_processed < args.p and len(packages_idxs) > 0:
|
while packages_processed < args.p and len(packages_idxs) > 0:
|
||||||
package = lib.get_package(lib.server_address, packages_idxs.pop())
|
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)
|
tgz = lib.download_package(work_path, package, None)
|
||||||
if tgz is None:
|
if tgz is None:
|
||||||
|
|
Loading…
Reference in New Issue