docs - Prevent eventlet exception during docs generation

build_sphinx has a lot of spurious tracebacks, We don't
really need this check for document generation

Change-Id: Id9442c5902918592c4c242cc66975062cf9f2461
This commit is contained in:
Davanum Srinivas 2014-07-27 21:37:30 -04:00 committed by Davanum Srinivas (dims)
parent 24a24fcf52
commit 365aae94cc
2 changed files with 13 additions and 2 deletions

View File

@ -16,13 +16,18 @@
# TODO(mikal): move eventlet imports to nova.__init__ once we move to PBR
import os
import sys
import traceback
# NOTE(mikal): All of this is because if dnspython is present in your
# environment then eventlet monkeypatches socket.getaddrinfo() with an
# implementation which doesn't work for IPv6. What we're checking here is
# that the magic environment variable was set when the import happened.
# NOTE(dims): Prevent this code from kicking in under docs generation
# as it leads to spurious errors/warning.
stack = traceback.extract_stack()
if ('eventlet' in sys.modules and
os.environ.get('EVENTLET_NO_GREENDNS', '').lower() != 'yes'):
os.environ.get('EVENTLET_NO_GREENDNS', '').lower() != 'yes' and
(len(stack) < 2 or 'sphinx' not in stack[-2][0])):
raise ImportError('eventlet imported before nova/cmd/__init__ '
'(env var set to %s)'
% os.environ.get('EVENTLET_NO_GREENDNS'))

View File

@ -25,13 +25,19 @@
# TODO(mikal): move eventlet imports to nova.__init__ once we move to PBR
import os
import sys
import traceback
# NOTE(mikal): All of this is because if dnspython is present in your
# environment then eventlet monkeypatches socket.getaddrinfo() with an
# implementation which doesn't work for IPv6. What we're checking here is
# that the magic environment variable was set when the import happened.
# NOTE(dims): Prevent this code from kicking in under docs generation
# as it leads to spurious errors/warning.
stack = traceback.extract_stack()
if ('eventlet' in sys.modules and
os.environ.get('EVENTLET_NO_GREENDNS', '').lower() != 'yes'):
os.environ.get('EVENTLET_NO_GREENDNS', '').lower() != 'yes' and
(len(stack) < 2 or 'sphinx' not in stack[-2][0])):
raise ImportError('eventlet imported before nova/cmd/__init__ '
'(env var set to %s)'
% os.environ.get('EVENTLET_NO_GREENDNS'))