3
3
1 . [ Scheduling tasks] ( ./SCHEDULE.md#1-scheduling-tasks )
4
4
2 . [ Overview] ( ./SCHEDULE.md#2-overview )
5
5
3 . [ Installation] ( ./SCHEDULE.md#3-installation )
6
- 4 . [ The schedule function] ( ./SCHEDULE.md#4-the-schedule-function ) The primary interface for uasyncio
6
+ 4 . [ The schedule function] ( ./SCHEDULE.md#4-the-schedule-function ) The primary interface for asyncio
7
7
4.1 [ Time specifiers] ( ./SCHEDULE.md#41-time-specifiers )
8
8
4.2 [ Calendar behaviour] ( ./SCHEDULE.md#42-calendar-behaviour ) Calendars can be tricky...
9
9
  ;  ;  ;  ;  ; 4.2.1 [ Behaviour of mday and wday values] ( ./SCHEDULE.md#421-behaviour-of-mday-and-wday-values )
@@ -37,8 +37,8 @@ It is partly inspired by the Unix cron table, also by the
37
37
latter it is less capable but is small, fast and designed for microcontroller
38
38
use. Repetitive and one-shot events may be created.
39
39
40
- It is ideally suited for use with ` uasyncio ` and basic use requires minimal
41
- ` uasyncio ` knowledge. Users intending only to schedule callbacks can simply
40
+ It is ideally suited for use with ` asyncio ` and basic use requires minimal
41
+ ` asyncio ` knowledge. Users intending only to schedule callbacks can simply
42
42
adapt the example code. It can be used in synchronous code and an example is
43
43
provided.
44
44
@@ -48,13 +48,13 @@ and the Unix build.
48
48
# 2. Overview
49
49
50
50
The ` schedule ` function (` sched/sched.py ` ) is the interface for use with
51
- ` uasyncio ` . The function takes a callback and causes that callback to run at
51
+ ` asyncio ` . The function takes a callback and causes that callback to run at
52
52
specified times. A coroutine may be substituted for the callback - at the
53
53
specified times it will be promoted to a ` Task ` and run.
54
54
55
55
The ` schedule ` function instantiates a ` cron ` object (in ` sched/cron.py ` ). This
56
56
is the core of the scheduler: it is a closure created with a time specifier and
57
- returning the time to the next scheduled event. Users of ` uasyncio ` do not need
57
+ returning the time to the next scheduled event. Users of ` asyncio ` do not need
58
58
to deal with ` cron ` instances.
59
59
60
60
This library can also be used in synchronous code, in which case ` cron `
@@ -64,23 +64,28 @@ instances must explicitly be created.
64
64
65
65
# 3. Installation
66
66
67
- Copy the ` sched ` directory and contents to the target's filesystem. It requires
68
- ` uasyncio ` V3 which is included in daily firmware builds and in release builds
69
- after V1.12.
70
-
71
- To install to an SD card using [ rshell] ( https://github.com/dhylands/rshell )
72
- move to the parent directory of ` sched ` and issue:
67
+ Copy the ` sched ` directory and contents to the target's filesystem. This may be
68
+ done with the official [ mpremote] ( https://docs.micropython.org/en/latest/reference/mpremote.html ) :
69
+ ``` bash
70
+ $ mpremote mip install " github:peterhinch/micropython-async/v3/as_drivers/sched"
71
+ ```
72
+ On networked platforms it may be installed with [ mip] ( https://docs.micropython.org/en/latest/reference/packages.html ) .
73
+ ``` py
74
+ >> > mip.install(" github:peterhinch/micropython-async/v3/as_drivers/sched" )
75
+ ```
76
+ Currently these tools install to ` /lib ` on the built-in Flash memory. To install
77
+ to a Pyboard's SD card [ rshell] ( https://github.com/dhylands/rshell ) may be used.
78
+ Move to the SD card root, run ` rshell ` and issue:
73
79
```
74
80
> rsync sched /sd/sched
75
81
```
76
- Adapt the destination as appropriate for your hardware.
77
82
78
83
The following files are installed in the ` sched ` directory.
79
84
1 . ` cron.py ` Computes time to next event.
80
- 2 . ` sched.py ` The ` uasyncio ` ` schedule ` function: schedule a callback or coro.
85
+ 2 . ` sched.py ` The ` asyncio ` ` schedule ` function: schedule a callback or coro.
81
86
3 . ` primitives/__init__.py ` Necessary for ` sched.py ` .
82
87
4 . ` asynctest.py ` Demo of asynchronous scheduling.
83
- 5 . ` synctest.py ` Synchronous scheduling demo. For ` uasyncio ` phobics only.
88
+ 5 . ` synctest.py ` Synchronous scheduling demo. For ` asyncio ` phobics only.
84
89
6 . ` crontest.py ` A test for ` cron.py ` code.
85
90
7 . ` simulate.py ` A simple script which may be adapted to prove that a ` cron `
86
91
instance will behave as expected. See [ The simulate script] ( ./SCHEDULE.md#8-the-simulate-script ) .
@@ -125,7 +130,7 @@ import sched.asynctest
125
130
```
126
131
This is the demo code.
127
132
``` python
128
- import uasyncio as asyncio
133
+ import asyncio as asyncio
129
134
from sched.sched import schedule
130
135
from time import localtime
131
136
@@ -157,7 +162,7 @@ finally:
157
162
```
158
163
The event-based interface can be simpler than using callables:
159
164
``` python
160
- import uasyncio as asyncio
165
+ import asyncio as asyncio
161
166
from sched.sched import schedule
162
167
from time import localtime
163
168
@@ -201,7 +206,7 @@ Setting `secs=None` will cause a `ValueError`.
201
206
202
207
Passing an iterable to ` secs ` is not recommended: this library is intended for
203
208
scheduling relatively long duration events. For rapid sequencing, schedule a
204
- coroutine which awaits ` uasyncio ` ` sleep ` or ` sleep_ms ` routines. If an
209
+ coroutine which awaits ` asyncio ` ` sleep ` or ` sleep_ms ` routines. If an
205
210
iterable is passed, triggers must be at least ten seconds apart or a
206
211
` ValueError ` will result.
207
212
@@ -253,7 +258,7 @@ asyncio.create_task(schedule(foo, month=(2, 7, 10), hrs=1, mins=59))
253
258
## 4.3 Limitations
254
259
255
260
The underlying ` cron ` code has a resolution of 1 second. The library is
256
- intended for scheduling infrequent events (` uasyncio ` has its own approach to
261
+ intended for scheduling infrequent events (` asyncio ` has its own approach to
257
262
fast scheduling).
258
263
259
264
Specifying ` secs=None ` will cause a ` ValueError ` . The minimum interval between
@@ -269,7 +274,7 @@ to the Unix build where daylight saving needs to be considered.
269
274
270
275
## 4.4 The Unix build
271
276
272
- Asynchronous use requires ` uasyncio ` V3, so ensure this is installed on the
277
+ Asynchronous use requires ` asyncio ` V3, so ensure this is installed on the
273
278
Linux target.
274
279
275
280
The synchronous and asynchronous demos run under the Unix build. The module is
@@ -283,7 +288,7 @@ is to avoid scheduling the times in your region where this occurs (01.00.00 to
283
288
284
289
# 5. The cron object
285
290
286
- This is the core of the scheduler. Users of ` uasyncio ` do not need to concern
291
+ This is the core of the scheduler. Users of ` asyncio ` do not need to concern
287
292
themseleves with it. It is documented for those wishing to modify the code and
288
293
for those wanting to perform scheduling in synchronous code.
289
294
@@ -342,7 +347,7 @@ applications. On my reference board timing drifted by 1.4mins/hr, an error of
342
347
343
348
Boards with internet connectivity can periodically synchronise to an NTP server
344
349
but this carries a risk of sudden jumps in the system time which may disrupt
345
- ` uasyncio ` and the scheduler.
350
+ ` asyncio ` and the scheduler.
346
351
347
352
##### [ Top] ( ./SCHEDULE.md#0-contents )
348
353
@@ -403,9 +408,9 @@ main()
403
408
```
404
409
405
410
In my opinion the asynchronous version is cleaner and easier to understand. It
406
- is also more versatile because the advanced features of ` uasyncio ` are
411
+ is also more versatile because the advanced features of ` asyncio ` are
407
412
available to the application including cancellation of scheduled tasks. The
408
- above code is incompatible with ` uasyncio ` because of the blocking calls to
413
+ above code is incompatible with ` asyncio ` because of the blocking calls to
409
414
` time.sleep() ` .
410
415
411
416
## 7.1 Initialisation
0 commit comments