Skip to content

Commit 83287db

Browse files
authored
Merge branch 'adafruit:main' into main
2 parents de19232 + cfb28ea commit 83287db

13 files changed

+24
-21
lines changed

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ jobs:
1212
steps:
1313
- name: Run Build CI workflow
1414
uses: adafruit/workflows-circuitpython-libs/build@main
15+
with:
16+
package-prefix: "asyncio"

.github/workflows/release_gh.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ jobs:
1515
- name: Run GitHub Release CI workflow
1616
uses: adafruit/workflows-circuitpython-libs/release-gh@main
1717
with:
18+
package-prefix: "asyncio"
1819
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
upload-url: ${{ github.event.release.upload_url }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ _build
3737

3838
# Virtual environment-specific files
3939
.env
40+
.venv
4041

4142
# MacOS-specific files
4243
*.DS_Store

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
repos:
66
- repo: https://github.com/python/black
7-
rev: 22.3.0
7+
rev: 23.3.0
88
hooks:
99
- id: black
1010
- repo: https://github.com/fsfe/reuse-tool
11-
rev: v0.14.0
11+
rev: v1.1.2
1212
hooks:
1313
- id: reuse
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.2.0
15+
rev: v4.4.0
1616
hooks:
1717
- id: check-yaml
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
2020
- repo: https://github.com/pycqa/pylint
21-
rev: v2.15.5
21+
rev: v2.17.4
2222
hooks:
2323
- id: pylint
2424
name: pylint (library code)

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,4 @@ min-public-methods=1
396396

397397
# Exceptions that will emit a warning when being caught. Defaults to
398398
# "Exception"
399-
overgeneral-exceptions=Exception
399+
overgeneral-exceptions=builtins.Exception

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Or the following command to update an existing version:
7373
Documentation
7474
=============
7575

76-
API documentation for this library can be found on `Read the Docs <https://circuitpython.readthedocs.io/en/latest/docs/library/asyncio.html>`_.
76+
API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/asyncio/en/latest/>`_.
7777

7878
For information on building library documentation, please check out
7979
`this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.

asyncio/core.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def sleep(t):
9494

9595
################################################################################
9696
# "Never schedule" object"
97-
# Don't re-schedule the object that awaits the _never singleton.
97+
# Don't re-schedule the object that awaits _never().
9898
# For internal use only. Some constructs, like `await event.wait()`,
9999
# work by NOT re-scheduling the task which calls wait(), but by
100100
# having some other task schedule it later.
101-
class _Never:
101+
class _NeverSingletonGenerator:
102102
def __init__(self):
103103
self.state = None
104104
self.exc = StopIteration()
@@ -117,7 +117,10 @@ def __next__(self):
117117
self.exc.__traceback__ = None
118118
raise self.exc
119119

120-
_never = _Never()
120+
def _never(sgen=_NeverSingletonGenerator()):
121+
# assert sgen.state is None, "Check for a missing `await` in your code"
122+
sgen.state = False
123+
return sgen
121124

122125

123126
################################################################################
@@ -150,13 +153,11 @@ def _dequeue(self, s):
150153

151154
async def queue_read(self, s):
152155
self._enqueue(s, 0)
153-
_never.state = False
154-
await _never
156+
await _never()
155157

156158
async def queue_write(self, s):
157159
self._enqueue(s, 1)
158-
_never.state = False
159-
await _never
160+
await _never()
160161

161162
def remove(self, task):
162163
while True:

asyncio/event.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ async def wait(self):
6262
self.waiting.push_head(core.cur_task)
6363
# Set calling task's data to the event's queue so it can be removed if needed
6464
core.cur_task.data = self.waiting
65-
core._never.state = False
66-
await core._never
65+
await core._never()
6766
return True
6867

6968

asyncio/lock.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ async def acquire(self):
6969
# Set calling task's data to the lock's queue so it can be removed if needed
7070
core.cur_task.data = self.waiting
7171
try:
72-
core._never.state = False
73-
await core._never
72+
await core._never()
7473
except core.CancelledError as er:
7574
if self.state == core.cur_task:
7675
# Cancelled while pending on resume, schedule next waiting Task

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# ones.
1818
extensions = [
1919
"sphinx.ext.autodoc",
20+
"sphinxcontrib.jquery",
2021
"sphinx.ext.intersphinx",
2122
"sphinx.ext.napoleon",
2223
"sphinx.ext.todo",

docs/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# SPDX-License-Identifier: Unlicense
44

55
sphinx>=4.0.0
6+
sphinxcontrib-jquery

examples/asyncio_displayio_button.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
label_color=BUTTON_LABEL_COLOR,
9999
)
100100

101+
101102
# Button state data object. Will hold either true of false whether button is currently pressed
102103
class ButtonState:
103104
# pylint: disable=too-few-public-methods
@@ -146,7 +147,6 @@ async def blink(palette, interval, count, button_state): # Don't forget the asy
146147
:param ButtonState button_state: The ButtonState data object for the invert color button
147148
"""
148149
while count < 0 or count > 0:
149-
150150
# if the color button is pressed
151151
if button_state.state:
152152
# if the color is still on default
@@ -187,7 +187,6 @@ def handle_color_button(touch_event, color_button, button_state):
187187

188188
# if there is a touch event
189189
if touch_event:
190-
191190
# if the color button is being touched
192191
if color_button.contains(touch_event):
193192
# set selected to change button color

examples/serial_examples.py

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import usb_cdc
2323

2424
async def usb_client():
25-
2625
usb_cdc.data.timeout = 0
2726
s = asyncio.StreamReader(usb_cdc.data)
2827
while True:
@@ -34,7 +33,6 @@ async def usb_client():
3433
import board
3534

3635
async def uart_client():
37-
3836
uart = board.UART()
3937
uart.timeout = 0
4038
s = asyncio.StreamReader(board.UART())

0 commit comments

Comments
 (0)