Skip to content

extmod/uasyncio: Fix syntax of generator functions #10190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion extmod/uasyncio/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def set(self):
def clear(self):
self.state = False

async def wait(self):
# async
def wait(self):
if not self.state:
# Event not set, put the calling task on the event's waiting queue
self.waiting.push(core.cur_task)
Expand Down
5 changes: 3 additions & 2 deletions extmod/uasyncio/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import core


def _run(waiter, aw):
async def _run(waiter, aw):
try:
result = await aw
status = True
Expand Down Expand Up @@ -61,7 +61,8 @@ def remove(t):
pass


async def gather(*aws, return_exceptions=False):
# async
def gather(*aws, return_exceptions=False):
if not aws:
return []

Expand Down
3 changes: 2 additions & 1 deletion extmod/uasyncio/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def release(self):
# No Task waiting so unlock
self.state = 0

async def acquire(self):
# async
def acquire(self):
if self.state != 0:
# Lock unavailable, put the calling Task on the waiting queue
self.waiting.push(core.cur_task)
Expand Down
21 changes: 14 additions & 7 deletions extmod/uasyncio/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ async def wait_closed(self):
# TODO yield?
self.s.close()

async def read(self, n=-1):
# async
def read(self, n=-1):
r = b""
while True:
yield core._io_queue.queue_read(self.s)
Expand All @@ -38,11 +39,13 @@ async def read(self, n=-1):
return r
r += r2

async def readinto(self, buf):
# async
def readinto(self, buf):
yield core._io_queue.queue_read(self.s)
return self.s.readinto(buf)

async def readexactly(self, n):
# async
def readexactly(self, n):
r = b""
while n:
yield core._io_queue.queue_read(self.s)
Expand All @@ -54,7 +57,8 @@ async def readexactly(self, n):
n -= len(r2)
return r

async def readline(self):
# async
def readline(self):
l = b""
while True:
yield core._io_queue.queue_read(self.s)
Expand All @@ -73,10 +77,11 @@ def write(self, buf):
buf = buf[ret:]
self.out_buf += buf

async def drain(self):
# async
def drain(self):
if not self.out_buf:
# Drain must always yield, so a tight loop of write+drain can't block the scheduler.
return await core.sleep_ms(0)
return (yield from core.sleep_ms(0))
mv = memoryview(self.out_buf)
off = 0
while off < len(mv):
Expand All @@ -93,7 +98,9 @@ async def drain(self):


# Create a TCP stream connection to a remote host
async def open_connection(host, port):
#
# async
def open_connection(host, port):
from uerrno import EINPROGRESS
import usocket as socket

Expand Down
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