Skip to content

Commit

Permalink
don't use yield; touch up documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalbert committed Aug 17, 2024
1 parent cf028c6 commit c6244bf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 29 deletions.
8 changes: 5 additions & 3 deletions asyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def sleep_ms(t, sgen=SingletonGenerator()):
# CIRCUITPY-CHANGE: doc
"""Sleep for *t* milliseconds.
This is a coroutine, and a MicroPython extension.
This is a MicroPython extension.
Returns a coroutine.
"""

# CIRCUITPY-CHANGE: add debugging hint
Expand All @@ -108,9 +110,9 @@ def sleep_ms(t, sgen=SingletonGenerator()):
# Pause task execution for the given time (in seconds)
def sleep(t):
# CIRCUITPY-CHANGE: doc
"""Sleep for *t* seconds
"""Sleep for *t* seconds.
This is a coroutine.
Returns a coroutine.
"""

return sleep_ms(int(t * 1000))
Expand Down
2 changes: 0 additions & 2 deletions asyncio/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ async def wait(self):
# CIRCUITPY-CHANGE: doc
"""Wait for the event to be set. If the event is already set then it returns
immediately.
This is a coroutine.
"""

if not self.state:
Expand Down
6 changes: 3 additions & 3 deletions asyncio/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ async def wait_for(aw, timeout, sleep=core.sleep):
this should be trapped by the caller.
Returns the return value of *aw*.
This is a coroutine.
"""

aw = core._promote_to_task(aw)
Expand Down Expand Up @@ -80,7 +78,9 @@ def wait_for_ms(aw, timeout):
# CIRCUITPY-CHANGE: doc
"""Similar to `wait_for` but *timeout* is an integer in milliseconds.
This is a coroutine, and a MicroPython extension.
This is a MicroPython extension.
Returns a coroutine.
"""

return wait_for(aw, timeout, core.sleep_ms)
Expand Down
2 changes: 0 additions & 2 deletions asyncio/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ async def acquire(self):
# CIRCUITPY-CHANGE: doc
"""Wait for the lock to be in the unlocked state and then lock it in an
atomic way. Only one task can acquire the lock at any one time.
This is a coroutine.
"""

if self.state != 0:
Expand Down
22 changes: 3 additions & 19 deletions asyncio/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def close(self):
async def wait_closed(self):
# CIRCUITPY-CHANGE: doc
"""Wait for the stream to close.
This is a coroutine.
"""

# TODO yield?
Expand All @@ -54,8 +52,6 @@ async def wait_closed(self):
async def read(self, n):
# CIRCUITPY-CHANGE: doc
"""Read up to *n* bytes and return them.
This is a coroutine.
"""

await core._io_queue.queue_read(self.s)
Expand All @@ -67,7 +63,7 @@ async def readinto(self, buf):
Return the number of bytes read into *buf*
This is a coroutine, and a MicroPython extension.
This is a MicroPython extension.
"""

# CIRCUITPY-CHANGE: await, not yield
Expand All @@ -81,9 +77,7 @@ async def readexactly(self, n):
Raises an ``EOFError`` exception if the stream ends before reading
*n* bytes.
This is a coroutine.
"""
"""

r = b""
while n:
Expand All @@ -101,8 +95,6 @@ async def readexactly(self, n):
async def readline(self):
# CIRCUITPY-CHANGE: doc
"""Read a line and return it.
This is a coroutine.
"""

l = b""
Expand Down Expand Up @@ -133,8 +125,6 @@ def write(self, buf):
async def drain(self):
# CIRCUITPY-CHANGE: doc
"""Drain (write) all buffered output data out to the stream.
This is a coroutine.
"""

mv = memoryview(self.out_buf)
Expand Down Expand Up @@ -162,8 +152,6 @@ async def open_connection(host, port, ssl=None, server_hostname=None):
Returns a pair of streams: a reader and a writer stream. Will raise a socket-specific
``OSError`` if the host could not be resolved or if the connection could not be made.
This is a coroutine.
"""

from uerrno import EINPROGRESS
Expand All @@ -188,7 +176,7 @@ async def open_connection(host, port, ssl=None, server_hostname=None):
s = ssl.wrap_socket(s, server_hostname=server_hostname, do_handshake_on_connect=False)
s.setblocking(False)
ss = Stream(s)
yield core._io_queue.queue_write(s)
await core._io_queue.queue_write(s)
return ss, ss


Expand All @@ -214,8 +202,6 @@ def close(self):

async def wait_closed(self):
"""Wait for the server to close.
This is a coroutine.
"""

await self.task
Expand Down Expand Up @@ -263,8 +249,6 @@ async def start_server(cb, host, port, backlog=5):
writer streams for the connection.
Returns a `Server` object.
This is a coroutine.
"""

import socket
Expand Down

0 comments on commit c6244bf

Please sign in to comment.