Skip to content

Commit 4e3964d

Browse files
committed
asyncio_micro: StreamReader, StreamWriter: add more methods.
1 parent 6f27ec1 commit 4e3964d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

asyncio_micro/asyncio_micro.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ class StreamReader:
186186
def __init__(self, s):
187187
self.s = s
188188

189+
def read(self, n):
190+
s = yield IORead(self.s)
191+
res = self.s.read(n)
192+
if not res:
193+
yield IODone(IO_READ, self.s)
194+
return res
195+
189196
def readline(self):
190197
log.debug("StreamReader.readline()")
191198
s = yield IORead(self.s)
@@ -208,6 +215,10 @@ def write(self, buf):
208215
s = yield IOWrite(self.s)
209216
log.debug("StreamWriter.write(): returning")
210217

218+
def close(self):
219+
yield IODone(IO_WRITE, self.s)
220+
self.s.close()
221+
211222

212223
def open_connection(host, port):
213224
log.debug("open_connection(%s, %s)", host, port)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy