summaryrefslogtreecommitdiff
path: root/Lib/socket.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index b2954b5a87..8b2d1cd1d6 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -199,6 +199,17 @@ class socket(_socket.socket):
if self._io_refs <= 0:
self._real_close()
+ def detach(self):
+ """detach() -> file descriptor
+
+ Close the socket object without closing the underlying file descriptor.
+ The object cannot be used after this call, but the file descriptor
+ can be reused for other purposes. The file descriptor is returned.
+ """
+ self._closed = True
+ return super().detach()
+
+
def fromfd(fd, family, type, proto=0):
""" fromfd(fd, family, type[, proto]) -> socket object