Skip to content

Commit 74c5668

Browse files
committed
extmod/uasyncio: Fix syntax of generator functions.
1 parent ab0258f commit 74c5668

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

extmod/uasyncio/event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def set(self):
2323
def clear(self):
2424
self.state = False
2525

26-
async def wait(self):
26+
# async
27+
def wait(self):
2728
if not self.state:
2829
# Event not set, put the calling task on the event's waiting queue
2930
self.waiting.push(core.cur_task)

extmod/uasyncio/funcs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from . import core
55

66

7-
def _run(waiter, aw):
7+
async def _run(waiter, aw):
88
try:
99
result = await aw
1010
status = True
@@ -61,7 +61,8 @@ def remove(t):
6161
pass
6262

6363

64-
async def gather(*aws, return_exceptions=False):
64+
# async
65+
def gather(*aws, return_exceptions=False):
6566
if not aws:
6667
return []
6768

extmod/uasyncio/lock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def release(self):
2828
# No Task waiting so unlock
2929
self.state = 0
3030

31-
async def acquire(self):
31+
# async
32+
def acquire(self):
3233
if self.state != 0:
3334
# Lock unavailable, put the calling Task on the waiting queue
3435
self.waiting.push(core.cur_task)

extmod/uasyncio/stream.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ async def wait_closed(self):
2626
# TODO yield?
2727
self.s.close()
2828

29-
async def read(self, n=-1):
29+
# async
30+
def read(self, n=-1):
3031
r = b""
3132
while True:
3233
yield core._io_queue.queue_read(self.s)
@@ -38,11 +39,13 @@ async def read(self, n=-1):
3839
return r
3940
r += r2
4041

41-
async def readinto(self, buf):
42+
# async
43+
def readinto(self, buf):
4244
yield core._io_queue.queue_read(self.s)
4345
return self.s.readinto(buf)
4446

45-
async def readexactly(self, n):
47+
# async
48+
def readexactly(self, n):
4649
r = b""
4750
while n:
4851
yield core._io_queue.queue_read(self.s)
@@ -54,7 +57,8 @@ async def readexactly(self, n):
5457
n -= len(r2)
5558
return r
5659

57-
async def readline(self):
60+
# async
61+
def readline(self):
5862
l = b""
5963
while True:
6064
yield core._io_queue.queue_read(self.s)
@@ -73,10 +77,11 @@ def write(self, buf):
7377
buf = buf[ret:]
7478
self.out_buf += buf
7579

76-
async def drain(self):
80+
# async
81+
def drain(self):
7782
if not self.out_buf:
7883
# Drain must always yield, so a tight loop of write+drain can't block the scheduler.
79-
return await core.sleep_ms(0)
84+
return (yield from core.sleep_ms(0))
8085
mv = memoryview(self.out_buf)
8186
off = 0
8287
while off < len(mv):
@@ -93,7 +98,9 @@ async def drain(self):
9398

9499

95100
# Create a TCP stream connection to a remote host
96-
async def open_connection(host, port):
101+
#
102+
# async
103+
def open_connection(host, port):
97104
from uerrno import EINPROGRESS
98105
import usocket as socket
99106

0 commit comments

Comments
 (0)