From 5b8073c7703c42a0b2b07536cd84e16ebf811b04 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 11 Sep 2020 11:46:00 -0700 Subject: [PATCH] py3: Fix swift-dispersion-populate We fixed swift-dispersion-report already; -populate needed the same fix or else it'd hit a "maximum recursion depth exceeded" error. Change-Id: I2d22e087a88c9e8003621feb26460ab6e5ce2a57 Related-Change: I24f4bcc3d62dc37fd9559032bfd25f5b15f98745 Closes-Bug: #1895346 Related-Bug: #1863680 --- bin/swift-dispersion-populate | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/swift-dispersion-populate b/bin/swift-dispersion-populate index d051630cdb..a54c77ed0e 100755 --- a/bin/swift-dispersion-populate +++ b/bin/swift-dispersion-populate @@ -27,10 +27,6 @@ import six from six.moves import range from six.moves.configparser import ConfigParser -try: - from swiftclient import get_auth -except ImportError: - from swift.common.internal_client import get_auth from swift.common.internal_client import SimpleClient from swift.common.ring import Ring from swift.common.utils import compute_eta, get_time_units, config_true_value @@ -88,6 +84,11 @@ def report(success): if __name__ == '__main__': global begun, created, item_type, next_report, need_to_create, retries_done patcher.monkey_patch() + try: + # Delay importing so urllib3 will import monkey-patched modules + from swiftclient import get_auth + except ImportError: + from swift.common.internal_client import get_auth conffile = '/etc/swift/dispersion.conf'