Skip to content

Fix uses of 'await sleep(0)' #30

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 6 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 2 additions & 5 deletions asyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
from adafruit_ticks import ticks_ms as ticks, ticks_diff, ticks_add
import sys, select, traceback

# Import TaskQueue and Task, preferring built-in C code over Python code
try:
from _asyncio import TaskQueue, Task
except:
from .task import TaskQueue, Task
# Import TaskQueue and Task, unconditionally preferring Python code
from .task import TaskQueue, Task


################################################################################
Expand Down
2 changes: 1 addition & 1 deletion asyncio/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def wait(self):
self.waiting.push_head(core.cur_task)
# Set calling task's data to the event's queue so it can be removed if needed
core.cur_task.data = self.waiting
await core.sleep(0)
yield
return True


Expand Down
2 changes: 1 addition & 1 deletion asyncio/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def gather(*aws, return_exceptions=False):
# # cancel all waiting tasks
# raise er
ts[i] = await ts[i]
except Exception as er:
except (core.CancelledError, Exception) as er:
if return_exceptions:
ts[i] = er
else:
Expand Down
2 changes: 1 addition & 1 deletion asyncio/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def acquire(self):
# Set calling task's data to the lock's queue so it can be removed if needed
core.cur_task.data = self.waiting
try:
await core.sleep(0)
yield
except core.CancelledError as er:
if self.state == core.cur_task:
# Cancelled while pending on resume, schedule next waiting Task
Expand Down