summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-10-09 16:16:26 (GMT)
committerYury Selivanov <yury@magic.io>2016-10-09 16:16:26 (GMT)
commitcfa6b72a47466daf144a58a42e5d905d351aab12 (patch)
tree33513f2e400ca0e00b2b02f535a3da87938aeaff /Lib/asyncio
parentf3fc3b06c432644fefa6fef84c1dfcd33dc283e7 (diff)
parent88e8aca78d71fa917a057e8d60b24f4a364d3248 (diff)
downloadcpython-cfa6b72a47466daf144a58a42e5d905d351aab12.zip
cpython-cfa6b72a47466daf144a58a42e5d905d351aab12.tar.gz
cpython-cfa6b72a47466daf144a58a42e5d905d351aab12.tar.bz2
Merge 3.6 (issue #28399)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/unix_events.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 8524ba9..2843678 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -258,6 +258,17 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ # Check for abstract socket. `str` and `bytes` paths are supported.
+ if path[0] not in (0, '\x00'):
+ try:
+ if stat.S_ISSOCK(os.stat(path).st_mode):
+ os.remove(path)
+ except FileNotFoundError:
+ pass
+ except OSError as err:
+ # Directory may have permissions only to create socket.
+ logger.error('Unable to check or remove stale UNIX socket %r: %r', path, err)
+
try:
sock.bind(path)
except OSError as exc: