|
74 | 74 | 7.6.1 [WiFi issues](./TUTORIAL.md#761-wifi-issues)
|
75 | 75 | 7.7 [CPython compatibility and the event loop](./TUTORIAL.md#77-cpython-compatibility-and-the-event-loop) Compatibility with CPython 3.5+
|
76 | 76 | 7.8 [Race conditions](./TUTORIAL.md#78-race-conditions)
|
| 77 | + 7.9 [Undocumented uasyncio features](./TUTORIAL.md#79-undocumented-uasyncio-features) |
77 | 78 | 8. [Notes for beginners](./TUTORIAL.md#8-notes-for-beginners)
|
78 | 79 | 8.1 [Problem 1: event loops](./TUTORIAL.md#81-problem-1:-event-loops)
|
79 | 80 | 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
|
2296 | 2297 | an infra red remote controller. The following notes are salient points
|
2297 | 2298 | regarding its `asyncio` usage.
|
2298 | 2299 |
|
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. |
2303 | 2304 |
|
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 |
2305 | 2306 | any `asyncio` latency when setting its delay period.
|
2306 | 2307 |
|
2307 | 2308 | ###### [Contents](./TUTORIAL.md#contents)
|
@@ -2461,8 +2462,8 @@ The second approach to socket programming is to use nonblocking sockets. This
|
2461 | 2462 | adds complexity but is necessary in some applications, notably where
|
2462 | 2463 | connectivity is via WiFi (see below).
|
2463 | 2464 |
|
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. |
2466 | 2467 |
|
2467 | 2468 | The use of nonblocking sockets requires some attention to detail. If a
|
2468 | 2469 | 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
|
2517 | 2518 | deprecated. To quote from the official docs:
|
2518 | 2519 |
|
2519 | 2520 | 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 |
2521 | 2522 | call its methods. This section is intended mostly for authors of lower-level
|
2522 | 2523 | code, libraries, and frameworks, who need finer control over the event loop
|
2523 | 2524 | 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.
|
2553 | 2554 | Alternatively a subsequent button press might be required to terminate the
|
2554 | 2555 | illumination. The "right" behaviour is application dependent.
|
2555 | 2556 |
|
| 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 | + |
2556 | 2569 | ###### [Contents](./TUTORIAL.md#contents)
|
2557 | 2570 |
|
2558 | 2571 | # 8 Notes for beginners
|
|
0 commit comments