Fix docs-building on old stable branches
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
This commit is contained in:
parent
eac5643380
commit
1af2dd6ac9
|
@ -808,7 +808,8 @@ class SloGetContext(WSGIContext):
|
||||||
plain_listing_iter = self._segment_listing_iterator(
|
plain_listing_iter = self._segment_listing_iterator(
|
||||||
req, ver, account, segments, byteranges)
|
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
|
start = 0 if start_byte is None else start_byte
|
||||||
end = int(seg_dict['bytes']) - 1 if end_byte is None else end_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
|
is_small = (end - start + 1) < self.slo.rate_limit_under_size
|
||||||
|
|
|
@ -21,9 +21,10 @@ import string
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from swift import gettext_ as _
|
from swift import gettext_ as _
|
||||||
from exceptions import PLOTLIBNotInstalled, ODFLIBNotInstalled,\
|
from swift.common.middleware.x_profile.exceptions import PLOTLIBNotInstalled,\
|
||||||
NotFoundException, MethodNotAllowed, DataLoadFailure, ProfileException
|
ODFLIBNotInstalled, NotFoundException, MethodNotAllowed, DataLoadFailure,\
|
||||||
from profile_model import Stats2
|
ProfileException
|
||||||
|
from swift.common.middleware.x_profile.profile_model import Stats2
|
||||||
|
|
||||||
PLOTLIB_INSTALLED = True
|
PLOTLIB_INSTALLED = True
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -79,17 +79,23 @@ import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from eventlet import greenthread, GreenPool, patcher
|
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
|
import six
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
|
|
||||||
from swift import gettext_ as _
|
from swift import gettext_ as _
|
||||||
from swift.common.utils import get_logger, config_true_value
|
from swift.common.utils import get_logger, config_true_value
|
||||||
from swift.common.swob import Request
|
from swift.common.swob import Request
|
||||||
from x_profile.exceptions import NotFoundException, MethodNotAllowed,\
|
from swift.common.middleware.x_profile.exceptions import NotFoundException, \
|
||||||
ProfileException
|
MethodNotAllowed, ProfileException
|
||||||
from x_profile.html_viewer import HTMLViewer
|
from swift.common.middleware.x_profile.html_viewer import HTMLViewer
|
||||||
from x_profile.profile_model import ProfileLog
|
from swift.common.middleware.x_profile.profile_model import ProfileLog
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_PROFILE_PREFIX = '/tmp/log/swift/profile/default.profile'
|
DEFAULT_PROFILE_PREFIX = '/tmp/log/swift/profile/default.profile'
|
||||||
|
@ -107,7 +113,10 @@ PROFILE_EXEC_LAZY = """
|
||||||
app_iter_ = self.app(environ, start_response)
|
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
|
# This monkey patch code fix the problem of eventlet profile tool
|
||||||
|
|
Loading…
Reference in New Issue