cotask module

Cooperative multitasking scheduler for MicroPython.

Contains classes to run cooperatively scheduled tasks in a multitasking system. Tasks are written as generator functions with infinite loops that call yield at least once per iteration. A CoTaskList maintains references to all active tasks and the scheduler runs each task’s run() method using round-robin or highest-priority-first scheduling.

author:

JR Ridgely

date:

2017-Jan-01 — original creation; 2021-Dec-18 — docstrings updated

copyright:

Copyright (c) 2017-2023 by JR Ridgely, released under the GNU Public License v3.0. Provided for educational use without warranty.

class cotask.Task(run_fun, name='NoName', priority=0, period=None, profile=False, trace=False, shares=())[source]

Bases: object

get_trace()[source]
go()[source]
ready()
Return type:

bool

reset_profile()[source]
schedule()[source]
Return type:

bool

set_period(new_period)[source]
class cotask.TaskList[source]

Bases: object

append(task)[source]
clear()[source]
pri_sched()
rr_sched()