mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
asyncio doc: socket.socketpair() is not available on Windows yet
This commit is contained in:
parent
04e6df330d
commit
ccd8e34508
3 changed files with 15 additions and 6 deletions
|
@ -296,11 +296,14 @@ Coroutine waiting until a socket receives data using the
|
|||
: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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue