Simple task library using asyncio.
Project description
docs |
|
|---|---|
package |
Simple task library using asyncio.
Free software: MIT License
Installation
pip install robot-tasks
You can also install the in-development version with:
pip install https://github.com/fmorton/robot-tasks/archive/main.zip
Tasks Example with a Birdbrain Robot
from robot.hummingbird import Hummingbird
from robot.tasks import Tasks
async def task_1(bird):
while True:
print("task_1 running")
await Tasks.yield_task(1.0)
async def task_2(bird):
while True:
print("task_2 running")
await Tasks.yield_task(0.5)
bird = Hummingbird("A")
tasks = Tasks()
tasks.create_task(task_1(bird))
tasks.create_task(task_2(bird))
tasks.run()
Processes Example with a Birdbrain Robot
import random
from robot.hummingbird import Hummingbird
from robot.processes import Processes
from time import sleep
def random_blinker(hummingbird):
for i in range(35):
hummingbird.tri_led(1, random.randint(0, 100), random.randint(0, 100), random.randint(0, 100))
sleep(0.1)
def blue_blinker(hummingbird):
for i in range(35):
hummingbird.tri_led(1, 0, 0, 100)
sleep(0.1)
if __name__ == '__main__':
hummingbird = Hummingbird('A')
processes = Processes()
processes.create_process(random_blinker, (hummingbird,))
processes.create_process(blue_blinker, (hummingbird,))
processes.run()
hummingbird.tri_led(1, 0, 0, 0)
Testing
To run all the tests run:
pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
robot_tasks-0.2.3.tar.gz
(7.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robot_tasks-0.2.3.tar.gz.
File metadata
- Download URL: robot_tasks-0.2.3.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7af056506852b12aad7e31a1afa6d77d8f293578beb833817bd4ff299614cd2b
|
|
| MD5 |
00660464fb3b8a51a7ed4f6bc88d7835
|
|
| BLAKE2b-256 |
79a9d7cea97ad27d574570a447cf30538e5692265cd04ab57cc176039112e65f
|
File details
Details for the file robot_tasks-0.2.3-py3-none-any.whl.
File metadata
- Download URL: robot_tasks-0.2.3-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34eea0a96bc7b704dccb7b9f650cb42a297bed7f01d9e06febfad428310f426f
|
|
| MD5 |
2aee327740b38f03ceeca5bc39fdfd68
|
|
| BLAKE2b-256 |
d4592172b23815fb81cd8fa5d5b7a76a9f64acd14a92883201f792ce2c761116
|