kopia lustrzana https://github.com/micropython/micropython-lib
asyncio_micro: StreamReader, StreamWriter: add more methods.
rodzic
1c647189f1
commit
b86919a6ff
|
@ -186,6 +186,13 @@ class StreamReader:
|
|||
def __init__(self, s):
|
||||
self.s = s
|
||||
|
||||
def read(self, n):
|
||||
s = yield IORead(self.s)
|
||||
res = self.s.read(n)
|
||||
if not res:
|
||||
yield IODone(IO_READ, self.s)
|
||||
return res
|
||||
|
||||
def readline(self):
|
||||
log.debug("StreamReader.readline()")
|
||||
s = yield IORead(self.s)
|
||||
|
@ -208,6 +215,10 @@ class StreamWriter:
|
|||
s = yield IOWrite(self.s)
|
||||
log.debug("StreamWriter.write(): returning")
|
||||
|
||||
def close(self):
|
||||
yield IODone(IO_WRITE, self.s)
|
||||
self.s.close()
|
||||
|
||||
|
||||
def open_connection(host, port):
|
||||
log.debug("open_connection(%s, %s)", host, port)
|
||||
|
|
Ładowanie…
Reference in New Issue