[Python-checkins] cpython (3.4): asyncio doc: socket.socketpair() is not available on Windows yet

victor.stinner python-checkins at python.org
Sat Oct 11 16:30:16 CEST 2014


https://hg.python.org/cpython/rev/a33b3bef2a1c
changeset:   92961:a33b3bef2a1c
branch:      3.4
parent:      92959:4cedc6a50912
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sat Oct 11 16:30:02 2014 +0200
summary:
  asyncio doc: socket.socketpair() is not available on Windows yet

files:
  Doc/library/asyncio-eventloop.rst |  7 +++++--
  Doc/library/asyncio-protocol.rst  |  7 +++++--
  Doc/library/asyncio-stream.rst    |  7 +++++--
  3 files changed, 15 insertions(+), 6 deletions(-)


diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -676,10 +676,13 @@
 :meth:`BaseEventLoop.add_reader` method and then close the event loop::
 
     import asyncio
-    import socket
+    try:
+        from socket import socketpair
+    except ImportError:
+        from asyncio.windows_utils import socketpair
 
     # Create a pair of connected file descriptors
-    rsock, wsock = socket.socketpair()
+    rsock, wsock = socketpair()
     loop = asyncio.get_event_loop()
 
     def reader():
diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst
--- a/Doc/library/asyncio-protocol.rst
+++ b/Doc/library/asyncio-protocol.rst
@@ -521,10 +521,13 @@
 the event loop ::
 
     import asyncio
-    import socket
+    try:
+        from socket import socketpair
+    except ImportError:
+        from asyncio.windows_utils import socketpair
 
     # Create a pair of connected sockets
-    rsock, wsock = socket.socketpair()
+    rsock, wsock = socketpair()
     loop = asyncio.get_event_loop()
 
     class MyProtocol(asyncio.Protocol):
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -296,11 +296,14 @@
 :func:`open_connection` function::
 
     import asyncio
-    import socket
+    try:
+        from socket import socketpair
+    except ImportError:
+        from asyncio.windows_utils import socketpair
 
     def wait_for_data(loop):
         # Create a pair of connected sockets
-        rsock, wsock = socket.socketpair()
+        rsock, wsock = socketpair()
 
         # Register the open socket to wait for data
         reader, writer = yield from asyncio.open_connection(sock=rsock, loop=loop)

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


More information about the Python-checkins mailing list