From 498ac6a72d0b33507078bf8c5980cb67ed9c3758 Mon Sep 17 00:00:00 2001 From: "Sungjun, Kim" Date: Mon, 5 Feb 2018 15:10:44 +0900 Subject: [PATCH] Handle ChunkedEncodingError on check_solvability_write_deps() (#398) * Fix [issue #381](https://github.com/ucbrise/clipper/issues/381) --- .../clipper_admin/deployers/check_and_write_deps.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/clipper_admin/clipper_admin/deployers/check_and_write_deps.py b/clipper_admin/clipper_admin/deployers/check_and_write_deps.py index 67a7e38da..ac85c3e03 100644 --- a/clipper_admin/clipper_admin/deployers/check_and_write_deps.py +++ b/clipper_admin/clipper_admin/deployers/check_and_write_deps.py @@ -2,6 +2,7 @@ from conda.api import get_index from conda.base.context import context from conda.exceptions import UnsatisfiableError, NoPackagesFoundError +from requests.exceptions import ChunkedEncodingError import conda.resolve import conda_env.specs as specs import sys @@ -66,7 +67,15 @@ def check_solvability_write_deps(env_path, directory, platform, on the container os. Otherwise returns False. """ - index = get_index(platform=platform) + def get_packages_index(tries=5): + for n in range(tries): + try: + return get_index(platform=platform) + except ChunkedEncodingError as e: + if n == tries - 1: + raise e + + index = get_packages_index() r = conda.resolve.Resolve(index) spec = specs.detect(filename=env_path) env = spec.environment