diff options
author | Sam Doran <sdoran@redhat.com> | 2020-11-20 14:10:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 13:10:58 -0600 |
commit | 103ae173c7a0a234f2017cb7973b278e3a5c9f24 (patch) | |
tree | dab5bf82866128056f9a76e3ac6f823196112927 | |
parent | c0be689295d55d51fb699e89a072896c6e30b806 (diff) | |
download | ansible-103ae173c7a0a234f2017cb7973b278e3a5c9f24.tar.gz |
[stable-2.8] Fix super annoying Python 2.6 multiprocessing.Queue stack trace in CI (#72604) (#72610)
* Fix super annoying Python 2.6 multiprocessing.Queue stack trace in CI
A bug exists in Python 2.6 that sometimes raises an exception during interpreter shutdown. We
encounter this frequently in our CI since we run tests on CentOS 6 as the control node, which
has Python 2.6.6 with this bug.
This PR adds a very minor sleep only on Python 2.6 which gets around this issue. I did lot of testing
using a standalon script I found that easily duplicated the issue to find the minimum sleep value
needed to avoid this issue.
CPython issue: https://bugs.python.org/issue4106
Fix in CPython: https://hg.python.org/cpython/rev/d316315a8781
* Use correct attribute
(cherry picked from commit bbef250c2b)
Co-authored-by: Sam Doran <sdoran@redhat.com>
-rw-r--r-- | changelogs/fragments/py26-multiprocess-queue-bug.yml | 2 | ||||
-rw-r--r-- | lib/ansible/executor/task_queue_manager.py | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/changelogs/fragments/py26-multiprocess-queue-bug.yml b/changelogs/fragments/py26-multiprocess-queue-bug.yml new file mode 100644 index 0000000000..c61cc55564 --- /dev/null +++ b/changelogs/fragments/py26-multiprocess-queue-bug.yml @@ -0,0 +1,2 @@ +bugfixes: + - account for bug in Python 2.6 that occurs during interpreter shutdown to avoid stack trace diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 9543a93441..2a1bdb0ea9 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -21,7 +21,9 @@ __metaclass__ = type import multiprocessing import os +import sys import tempfile +import time from ansible import constants as C from ansible import context @@ -262,6 +264,22 @@ class TaskQueueManager: self._final_q.close() 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): if hasattr(self, '_workers'): for worker_prc in self._workers: |