Skip to content

Commit b8f7fa2

Browse files
committed
TUTORIAL.md: Add undocumented features.
1 parent 12a7a03 commit b8f7fa2

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

v3/docs/TUTORIAL.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ REPL.
7474
     7.6.1 [WiFi issues](./TUTORIAL.md#761-wifi-issues)
7575
7.7 [CPython compatibility and the event loop](./TUTORIAL.md#77-cpython-compatibility-and-the-event-loop) Compatibility with CPython 3.5+
7676
7.8 [Race conditions](./TUTORIAL.md#78-race-conditions)
77+
7.9 [Undocumented uasyncio features](./TUTORIAL.md#79-undocumented-uasyncio-features)
7778
8. [Notes for beginners](./TUTORIAL.md#8-notes-for-beginners)
7879
8.1 [Problem 1: event loops](./TUTORIAL.md#81-problem-1:-event-loops)
7980
8.2 [Problem 2: blocking methods](./TUTORIAL.md#8-problem-2:-blocking-methods)
@@ -2296,12 +2297,12 @@ See [aremote.py](../as_drivers/nec_ir/aremote.py) documented
22962297
an infra red remote controller. The following notes are salient points
22972298
regarding its `asyncio` usage.
22982299

2299-
A pin interrupt records the time of a state change (in μs) and sets an event,
2300-
passing the time when the first state change occurred. A task waits on the
2301-
event, yields for the duration of a data burst, then decodes the stored data
2302-
before calling a user-specified callback.
2300+
A pin interrupt records the time of a state change (in μs) and sends a
2301+
`Message`, passing the time when the first state change occurred. A task waits
2302+
on the `Message`, yields for the duration of a data burst, then decodes the
2303+
stored data before calling a user-specified callback.
23032304

2304-
Passing the time to the `Event` instance enables the task to compensate for
2305+
Passing the time to the `Message` instance enables the task to compensate for
23052306
any `asyncio` latency when setting its delay period.
23062307

23072308
###### [Contents](./TUTORIAL.md#contents)
@@ -2461,8 +2462,8 @@ The second approach to socket programming is to use nonblocking sockets. This
24612462
adds complexity but is necessary in some applications, notably where
24622463
connectivity is via WiFi (see below).
24632464

2464-
Support for TLS on nonblocking sockets is platform dependent. It works on ESP32
2465-
and Pyboard D. It does not work on ESP8266.
2465+
Support for TLS on nonblocking sockets is platform dependent. It works on ESP32,
2466+
Pyboard D and ESP8266.
24662467

24672468
The use of nonblocking sockets requires some attention to detail. If a
24682469
nonblocking read is performed, because of server latency, there is no guarantee
@@ -2517,7 +2518,7 @@ Event loop methods are supported in `uasyncio` and in CPython 3.8 but are
25172518
deprecated. To quote from the official docs:
25182519

25192520
Application developers should typically use the high-level asyncio functions,
2520-
such as asyncio.run(), and should rarely need to reference the loop object or
2521+
such as `asyncio.run()`, and should rarely need to reference the loop object or
25212522
call its methods. This section is intended mostly for authors of lower-level
25222523
code, libraries, and frameworks, who need finer control over the event loop
25232524
behavior. [reference](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop).
@@ -2553,6 +2554,18 @@ one is running, or to extend the timer to prolong the LED illumination.
25532554
Alternatively a subsequent button press might be required to terminate the
25542555
illumination. The "right" behaviour is application dependent.
25552556

2557+
## 7.9 Undocumented uasyncio features
2558+
2559+
These may be subject to change.
2560+
2561+
A `Task` instance has a `.done()` method that returns `True` if the task has
2562+
terminated (by running to completion, by throwing an exception or by being
2563+
cancelled).
2564+
2565+
If a task has completed, a `.data` bound variable holds any result which was
2566+
returned by the task. If the task throws an exception or is cancelled `.data`
2567+
holds the exception (or `CancelledError`).
2568+
25562569
###### [Contents](./TUTORIAL.md#contents)
25572570

25582571
# 8 Notes for beginners

0 commit comments

Comments
 (0)