kopia lustrzana https://github.com/micropython/micropython-lib
cpython-uasyncio: Add StreamWriter with awrite() & aclose().
rodzic
083ad0e94c
commit
e413ba6d87
|
@ -1,3 +1,3 @@
|
||||||
srctype = cpython-backport
|
srctype = cpython-backport
|
||||||
type = module
|
type = module
|
||||||
version = 0.1
|
version = 0.2
|
||||||
|
|
|
@ -6,7 +6,7 @@ from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
setup(name='micropython-cpython-uasyncio',
|
setup(name='micropython-cpython-uasyncio',
|
||||||
version='0.1',
|
version='0.2',
|
||||||
description='MicroPython module uasyncio ported to CPython',
|
description='MicroPython module uasyncio ported to CPython',
|
||||||
long_description='This is MicroPython compatibility module, allowing applications using\nMicroPython-specific features to run on CPython.\n',
|
long_description='This is MicroPython compatibility module, allowing applications using\nMicroPython-specific features to run on CPython.\n',
|
||||||
url='https://github.com/micropython/micropython/issues/405',
|
url='https://github.com/micropython/micropython/issues/405',
|
||||||
|
|
|
@ -78,3 +78,22 @@ class Task(OrgTask):
|
||||||
|
|
||||||
|
|
||||||
asyncio.tasks.Task = Task
|
asyncio.tasks.Task = Task
|
||||||
|
|
||||||
|
|
||||||
|
OrgStreamWriter = StreamWriter
|
||||||
|
|
||||||
|
class StreamWriter(OrgStreamWriter):
|
||||||
|
|
||||||
|
def awrite(self, data):
|
||||||
|
if isinstance(data, str):
|
||||||
|
data = data.encode("utf-8")
|
||||||
|
self.write(data)
|
||||||
|
yield from self.drain()
|
||||||
|
|
||||||
|
def aclose(self):
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
asyncio.streams.StreamWriter = StreamWriter
|
||||||
|
|
Ładowanie…
Reference in New Issue