cpython: 8967d9a1bc17 (original) (raw)

Mercurial > cpython

changeset 91930:8967d9a1bc17

Merge with Python 3.4 (asyncio) - Close #22063: socket operations (socket,recv, sock_sendall, sock_connect, sock_accept) now raise an exception in debug mode if sockets are in blocking mode. - asyncio: Use the new os.set_blocking() function of Python 3.5 if available [#22063]

Victor Stinner victor.stinner@gmail.com
date Tue, 29 Jul 2014 23:09:56 +0200
parents 129951f3d16f(current diff)7e70ec207889(diff)
children 741e58bcaa65
files Lib/asyncio/unix_events.py Lib/test/test_asyncio/test_events.py Lib/test/test_asyncio/test_unix_events.py
diffstat 5 files changed, 48 insertions(+), 4 deletions(-)[+] [-] Lib/asyncio/proactor_events.py 8 Lib/asyncio/selector_events.py 8 Lib/asyncio/unix_events.py 14 Lib/test/test_asyncio/test_events.py 18 Lib/test/test_asyncio/test_unix_events.py 4

line wrap: on

line diff

--- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -385,12 +385,18 @@ class BaseProactorEventLoop(base_events. self._selector = None def sock_recv(self, sock, n):

def sock_sendall(self, sock, data):

def sock_connect(self, sock, address):

@@ -401,6 +407,8 @@ class BaseProactorEventLoop(base_events. return self._proactor.connect(sock, address) def sock_accept(self, sock):

def _socketpair(self):

--- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -256,6 +256,8 @@ class BaseSelectorEventLoop(base_events. This method is a coroutine. """

@@ -292,6 +294,8 @@ class BaseSelectorEventLoop(base_events. This method is a coroutine. """

@@ -333,6 +337,8 @@ class BaseSelectorEventLoop(base_events. This method is a coroutine. """

@@ -374,6 +380,8 @@ class BaseSelectorEventLoop(base_events. This method is a coroutine. """

--- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -258,6 +258,16 @@ class _UnixSelectorEventLoop(selector_ev return server +if hasattr(os, 'set_blocking'):

+else:

+ + class _UnixReadPipeTransport(transports.ReadTransport): max_size = 256 * 1024 # max bytes we read in one event loop iteration @@ -273,7 +283,7 @@ class _UnixReadPipeTransport(transports. stat.S_ISSOCK(mode) or stat.S_ISCHR(mode)): raise ValueError("Pipe transport is for pipes/sockets only.")

@@ -366,7 +376,7 @@ class _UnixWritePipeTransport(transports stat.S_ISCHR(mode)): raise ValueError("Pipe transport is only for " "pipes, sockets and character devices")

--- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -383,6 +383,24 @@ class EventLoopTestsMixin: self.assertEqual(read, data) def _basetest_sock_client_ops(self, httpd, sock):

+

--- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -306,7 +306,7 @@ class UnixReadPipeTransportTests(test_ut self.pipe = mock.Mock(spec_set=io.RawIOBase) self.pipe.fileno.return_value = 5

@@ -469,7 +469,7 @@ class UnixWritePipeTransportTests(test_u self.pipe = mock.Mock(spec_set=io.RawIOBase) self.pipe.fileno.return_value = 5