summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/streams.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-13 19:15:56 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-13 19:15:56 (GMT)
commitd08c363c26f8437dddf3e4babd8065ab3a361518 (patch)
tree6f4cd65df5f6ec571e6985728ddc15afc6e9c638 /Lib/asyncio/streams.py
parent3a81f9ba46005e6876310283a67379d50304ebca (diff)
downloadcpython-d08c363c26f8437dddf3e4babd8065ab3a361518.zip
cpython-d08c363c26f8437dddf3e4babd8065ab3a361518.tar.gz
cpython-d08c363c26f8437dddf3e4babd8065ab3a361518.tar.bz2
Sync asyncio code from default branch.
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r--Lib/asyncio/streams.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 64ff3d2..176c65e 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -6,6 +6,7 @@ __all__ = ['StreamReader', 'StreamWriter', 'StreamReaderProtocol',
]
import socket
+import sys
if hasattr(socket, 'AF_UNIX'):
__all__.extend(['open_unix_connection', 'start_unix_server'])
@@ -19,6 +20,7 @@ from .log import logger
_DEFAULT_LIMIT = 2**16
+_PY35 = sys.version_info >= (3, 5)
class IncompleteReadError(EOFError):
@@ -485,3 +487,15 @@ class StreamReader:
n -= len(block)
return b''.join(blocks)
+
+ if _PY35:
+ @coroutine
+ def __aiter__(self):
+ return self
+
+ @coroutine
+ def __anext__(self):
+ val = yield from self.readline()
+ if val == b'':
+ raise StopAsyncIteration
+ return val