diff options
author | Tim Burke <tim.burke@gmail.com> | 2022-04-19 13:36:44 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2022-04-19 22:48:19 -0700 |
commit | 1af2dd6ac941a230cc0e7e8930646e38b02107b2 (patch) | |
tree | 384a13dba5d2a682194da4108629820e3c2ccc64 | |
parent | eac5643380dc38142500b81079f5055967c016ba (diff) | |
download | swift-pike-eol.tar.gz |
Fix docs-building on old stable branchespike-eol
For a while now, the nightly job has bombed out with something like
Warning, treated as error:
.../swift/doc/source/middleware.rst:268: (WARNING/2) autodoc: failed to import module
'swift.common.middleware.xprofile'; the following exception was raised:
Traceback (most recent call last):
File ".../python3.5/site-packages/sphinx/ext/autodoc.py", line 657, in import_object
__import__(self.modname)
File ".../python3.5/site-packages/swift/common/middleware/xprofile.py", line 82, in <module>
import eventlet.green.profile as eprofile
File ".../python3.5/site-packages/eventlet/green/profile.py", line 45, in <module>
thread = patcher.original('thread') # non-monkeypatched module needed
File ".../python3.5/site-packages/eventlet/patcher.py", line 194, in original
real_mod = __import__(modname, {}, {}, modname.split('.')[:-1])
ImportError: No module named 'thread'
Not sure why we're running under py35 (the job definition calls out
`sphinx_python: python2`), but that's the crux of the issue -- neither
us nor our dependencies support py3 that far back, so having eventlet
constrained to 0.20.0 on stable/pike and stable/queens is setting us up
for failure.
On the plus side, it's just docs! We don't really *need* this import to
build docs, so catch the ImportError and call it None.
After that, also need to fix some import for xprofile.
Also, fix some tuple-unpacking-in-function-args trouble.
Related-Change: Ie8d28218b974a1b6b7b7b691f786ff1d6bdded05
Change-Id: I56f10d8e25e57da59f3da57fe797f615433d70a7
-rw-r--r-- | swift/common/middleware/slo.py | 3 | ||||
-rw-r--r-- | swift/common/middleware/x_profile/html_viewer.py | 7 | ||||
-rw-r--r-- | swift/common/middleware/xprofile.py | 21 |
3 files changed, 21 insertions, 10 deletions
diff --git a/swift/common/middleware/slo.py b/swift/common/middleware/slo.py index 17dc147a0..9629d3838 100644 --- a/swift/common/middleware/slo.py +++ b/swift/common/middleware/slo.py @@ -808,7 +808,8 @@ class SloGetContext(WSGIContext): plain_listing_iter = self._segment_listing_iterator( req, ver, account, segments, byteranges) - def is_small_segment((seg_dict, start_byte, end_byte)): + def is_small_segment(args): + seg_dict, start_byte, end_byte = args start = 0 if start_byte is None else start_byte end = int(seg_dict['bytes']) - 1 if end_byte is None else end_byte is_small = (end - start + 1) < self.slo.rate_limit_under_size diff --git a/swift/common/middleware/x_profile/html_viewer.py b/swift/common/middleware/x_profile/html_viewer.py index b575c5383..d9256d4b5 100644 --- a/swift/common/middleware/x_profile/html_viewer.py +++ b/swift/common/middleware/x_profile/html_viewer.py @@ -21,9 +21,10 @@ import string import tempfile from swift import gettext_ as _ -from exceptions import PLOTLIBNotInstalled, ODFLIBNotInstalled,\ - NotFoundException, MethodNotAllowed, DataLoadFailure, ProfileException -from profile_model import Stats2 +from swift.common.middleware.x_profile.exceptions import PLOTLIBNotInstalled,\ + ODFLIBNotInstalled, NotFoundException, MethodNotAllowed, DataLoadFailure,\ + ProfileException +from swift.common.middleware.x_profile.profile_model import Stats2 PLOTLIB_INSTALLED = True try: diff --git a/swift/common/middleware/xprofile.py b/swift/common/middleware/xprofile.py index deca857f2..68a6b4a71 100644 --- a/swift/common/middleware/xprofile.py +++ b/swift/common/middleware/xprofile.py @@ -79,17 +79,23 @@ import sys import time from eventlet import greenthread, GreenPool, patcher -import eventlet.green.profile as eprofile +try: + import eventlet.green.profile as eprofile +except ImportError: + # This is specifically for docs-building on old stable branches which have + # eventlet constrained to a version that doesn't include + # https://github.com/eventlet/eventlet/commit/f81b135a + eprofile = None import six from six.moves import urllib from swift import gettext_ as _ from swift.common.utils import get_logger, config_true_value from swift.common.swob import Request -from x_profile.exceptions import NotFoundException, MethodNotAllowed,\ - ProfileException -from x_profile.html_viewer import HTMLViewer -from x_profile.profile_model import ProfileLog +from swift.common.middleware.x_profile.exceptions import NotFoundException, \ + MethodNotAllowed, ProfileException +from swift.common.middleware.x_profile.html_viewer import HTMLViewer +from swift.common.middleware.x_profile.profile_model import ProfileLog DEFAULT_PROFILE_PREFIX = '/tmp/log/swift/profile/default.profile' @@ -107,7 +113,10 @@ PROFILE_EXEC_LAZY = """ app_iter_ = self.app(environ, start_response) """ -thread = patcher.original('thread') # non-monkeypatched module needed +if six.PY3: + thread = patcher.original('_thread') # non-monkeypatched module needed +else: + thread = patcher.original('thread') # non-monkeypatched module needed # This monkey patch code fix the problem of eventlet profile tool |