diff options
author | Matt Martz <matt@sivel.net> | 2019-11-12 15:01:27 -0600 |
---|---|---|
committer | Matt Davis <nitzmahone@users.noreply.github.com> | 2019-11-12 13:01:27 -0800 |
commit | 20735f6b5b8ce664a9909f9cb5cbffa944b8c627 (patch) | |
tree | 934bd16992739611d0c061a7634617d264fb89b2 /lib/ansible/utils | |
parent | 14b48062eeb84c8ba81d910f16acf21ff680d3be (diff) | |
download | ansible-20735f6b5b8ce664a9909f9cb5cbffa944b8c627.tar.gz |
[stable-2.9] Explicitly use multiprocessing fork start method (#63581) (#63591)
* Explicitly use multiprocessing fork start method
* Remove unused import
* Remove unused import
* Fallback to just multiprocessing on py2
(cherry picked from commit 82ee341)
Co-authored-by: Matt Martz <matt@sivel.net>
Diffstat (limited to 'lib/ansible/utils')
-rw-r--r-- | lib/ansible/utils/multiprocessing.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/ansible/utils/multiprocessing.py b/lib/ansible/utils/multiprocessing.py new file mode 100644 index 0000000000..dcc186597a --- /dev/null +++ b/lib/ansible/utils/multiprocessing.py @@ -0,0 +1,21 @@ +# Copyright (c) 2019 Matt Martz <matt@sivel.net> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import multiprocessing + +# Explicit multiprocessing context using the fork start method +# This exists as a compat layer now that Python3.8 has changed the default +# start method for macOS to ``spawn`` which is incompatible with our +# code base currently +# +# This exists in utils to allow it to be easily imported into various places +# without causing circular import or dependency problems +try: + context = multiprocessing.get_context('fork') +except AttributeError: + # Py2 has no context functionality, and only supports fork + context = multiprocessing |