diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-03-09 13:48:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 13:48:01 +0000 |
commit | 6012f30beff7fa8396718dfb198ccafc333c565b (patch) | |
tree | 54b0c8bbb4cc1c76ca7206edbd6133f71fc4d95c /Lib/multiprocessing/util.py | |
parent | dccd41e29fb9e75ac53c04ed3b097f51f8f65c4e (diff) | |
download | cpython-git-6012f30beff7fa8396718dfb198ccafc333c565b.tar.gz |
bpo-39850: Add support for abstract sockets in multiprocessing (GH-18866)
Diffstat (limited to 'Lib/multiprocessing/util.py')
-rw-r--r-- | Lib/multiprocessing/util.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index 4bc7782c00..32c7a96d25 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -102,6 +102,29 @@ def log_to_stderr(level=None): _log_to_stderr = True return _logger + +# Abstract socket support + +def _platform_supports_abstract_sockets(): + if sys.platform == "linux": + return True + if hasattr(sys, 'getandroidapilevel'): + return True + return False + + +def is_abstract_socket_namespace(address): + if not address: + return False + if isinstance(address, bytes): + return address[0] == 0 + elif isinstance(address, str): + return address[0] == "\0" + raise TypeError('address type of {address!r} unrecognized') + + +abstract_sockets_supported = _platform_supports_abstract_sockets() + # # Function returning a temp directory which will be removed on exit # |