summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/windows_events.py
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-10-19 19:46:40 (GMT)
committerYury Selivanov <yury@magic.io>2017-10-19 19:46:40 (GMT)
commit525f40d231aba2c004619fc7a5207171ed65b0cb (patch)
tree60cda8363e0c027aa17a6bb4288d9436aa228829 /Lib/asyncio/windows_events.py
parentea2ef5d0ca869d4550820ed53bdf56013dbb9546 (diff)
downloadcpython-525f40d231aba2c004619fc7a5207171ed65b0cb.zip
cpython-525f40d231aba2c004619fc7a5207171ed65b0cb.tar.gz
cpython-525f40d231aba2c004619fc7a5207171ed65b0cb.tar.bz2
bpo-31819: Add AbstractEventLoop.sock_recv_into() (#4051)
* bpo-31819: Add AbstractEventLoop.sock_recv_into() * Add NEWS * Add doc
Diffstat (limited to 'Lib/asyncio/windows_events.py')
-rw-r--r--Lib/asyncio/windows_events.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index b777dd0..6045ba0 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -448,6 +448,28 @@ class IocpProactor:
return self._register(ov, conn, finish_recv)
+ def recv_into(self, conn, buf, flags=0):
+ self._register_with_iocp(conn)
+ ov = _overlapped.Overlapped(NULL)
+ try:
+ if isinstance(conn, socket.socket):
+ ov.WSARecvInto(conn.fileno(), buf, flags)
+ else:
+ ov.ReadFileInto(conn.fileno(), buf)
+ except BrokenPipeError:
+ return self._result(b'')
+
+ def finish_recv(trans, key, ov):
+ try:
+ return ov.getresult()
+ except OSError as exc:
+ if exc.winerror == _overlapped.ERROR_NETNAME_DELETED:
+ raise ConnectionResetError(*exc.args)
+ else:
+ raise
+
+ return self._register(ov, conn, finish_recv)
+
def send(self, conn, buf, flags=0):
self._register_with_iocp(conn)
ov = _overlapped.Overlapped(NULL)