[Python-checkins] cpython: os.dup()-then-close() can be replaced with detach()

antoine.pitrou python-checkins at python.org
Mon May 9 21:00:47 CEST 2011


http://hg.python.org/cpython/rev/ac4b7b1a442e
changeset:   69990:ac4b7b1a442e
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon May 09 21:00:28 2011 +0200
summary:
  os.dup()-then-close() can be replaced with detach()

files:
  Lib/multiprocessing/connection.py |  6 ++----
  1 files changed, 2 insertions(+), 4 deletions(-)


diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -469,10 +469,8 @@
         '''
         if duplex:
             s1, s2 = socket.socketpair()
-            c1 = Connection(os.dup(s1.fileno()))
-            c2 = Connection(os.dup(s2.fileno()))
-            s1.close()
-            s2.close()
+            c1 = Connection(s1.detach())
+            c2 = Connection(s2.detach())
         else:
             fd1, fd2 = os.pipe()
             c1 = Connection(fd1, writable=False)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list