Remove obsolete Python 2.x controller code.

pull/77245/head
Matt Clay 3 years ago
parent f68c66a3ef
commit 6f445ca6e5

@ -130,11 +130,9 @@ class WorkerProcess(multiprocessing_context.Process): # type: ignore[name-defin
# shutdown. We have various ``Display`` calls that may fire from a fork # shutdown. We have various ``Display`` calls that may fire from a fork
# so we cannot do this early. Instead, this happens at the very end # so we cannot do this early. Instead, this happens at the very end
# to avoid that deadlock, by simply side stepping it. This should not be # to avoid that deadlock, by simply side stepping it. This should not be
# treated as a long term fix. Additionally this behavior only presents itself # treated as a long term fix.
# on Python3. Python2 does not exhibit the deadlock behavior.
# TODO: Evaluate overhauling ``Display`` to not write directly to stdout # TODO: Evaluate overhauling ``Display`` to not write directly to stdout
# and evaluate migrating away from the ``fork`` multiprocessing start method. # and evaluate migrating away from the ``fork`` multiprocessing start method.
if sys.version_info[0] >= 3:
sys.stdout = sys.stderr = open(os.devnull, 'w') sys.stdout = sys.stderr = open(os.devnull, 'w')
def _run(self): def _run(self):

@ -338,22 +338,6 @@ class TaskQueueManager:
self._final_q.close() self._final_q.close()
self._cleanup_processes() self._cleanup_processes()
# A bug exists in Python 2.6 that causes an exception to be raised during
# interpreter shutdown. This is only an issue in our CI testing but we
# hit it frequently enough to add a small sleep to avoid the issue.
# This can be removed once we have split controller available in CI.
#
# Further information:
# Issue: https://bugs.python.org/issue4106
# Fix: https://hg.python.org/cpython/rev/d316315a8781
#
try:
if (2, 6) == (sys.version_info[0:2]):
time.sleep(0.0001)
except (IndexError, AttributeError):
# In case there is an issue getting the version info, don't raise an Exception
pass
def _cleanup_processes(self): def _cleanup_processes(self):
if hasattr(self, '_workers'): if hasattr(self, '_workers'):
for attempts_remaining in range(C.WORKER_SHUTDOWN_POLL_COUNT - 1, -1, -1): for attempts_remaining in range(C.WORKER_SHUTDOWN_POLL_COUNT - 1, -1, -1):

@ -384,13 +384,6 @@ class CallbackBase(AnsiblePlugin):
tofiledate=u'', tofiledate=u'',
n=C.DIFF_CONTEXT) n=C.DIFF_CONTEXT)
difflines = list(differ) difflines = list(differ)
if len(difflines) >= 3 and sys.version_info[:2] == (2, 6):
# difflib in Python 2.6 adds trailing spaces after
# filenames in the -- before/++ after headers.
difflines[0] = difflines[0].replace(u' \n', u'\n')
difflines[1] = difflines[1].replace(u' \n', u'\n')
# it also treats empty files differently
difflines[2] = difflines[2].replace(u'-1,0', u'-0,0').replace(u'+1,0', u'+0,0')
has_diff = False has_diff = False
for line in difflines: for line in difflines:
has_diff = True has_diff = True

@ -264,8 +264,7 @@ class Display(metaclass=Singleton):
msg2 = msg2 + u'\n' msg2 = msg2 + u'\n'
msg2 = to_bytes(msg2, encoding=self._output_encoding(stderr=stderr)) msg2 = to_bytes(msg2, encoding=self._output_encoding(stderr=stderr))
if sys.version_info >= (3,): # Convert back to text string
# Convert back to text string on python3
# We first convert to a byte string so that we get rid of # We first convert to a byte string so that we get rid of
# characters that are invalid in the user's locale # characters that are invalid in the user's locale
msg2 = to_text(msg2, self._output_encoding(stderr=stderr), errors='replace') msg2 = to_text(msg2, self._output_encoding(stderr=stderr), errors='replace')
@ -292,8 +291,7 @@ class Display(metaclass=Singleton):
# color and characters that are invalid in the user's locale # color and characters that are invalid in the user's locale
msg2 = to_bytes(nocolor.lstrip(u'\n')) msg2 = to_bytes(nocolor.lstrip(u'\n'))
if sys.version_info >= (3,): # Convert back to text string
# Convert back to text string on python3
msg2 = to_text(msg2, self._output_encoding(stderr=stderr)) msg2 = to_text(msg2, self._output_encoding(stderr=stderr))
lvl = logging.INFO lvl = logging.INFO
@ -463,8 +461,7 @@ class Display(metaclass=Singleton):
@staticmethod @staticmethod
def prompt(msg, private=False): def prompt(msg, private=False):
prompt_string = to_bytes(msg, encoding=Display._output_encoding()) prompt_string = to_bytes(msg, encoding=Display._output_encoding())
if sys.version_info >= (3,): # Convert back into text. We do this double conversion
# Convert back into text on python3. We do this double conversion
# to get rid of characters that are illegal in the user's locale # to get rid of characters that are illegal in the user's locale
prompt_string = to_text(prompt_string) prompt_string = to_text(prompt_string)

Loading…
Cancel
Save