Metadata-Version: 2.4
Name: robot-tasks
Version: 0.2.3
Summary: Simple task library using asyncio.
Project-URL: Documentation, https://github.com/fmorton/robot-tasks#readme
Project-URL: Issues, https://github.com/fmorton/robot-tasks/issues
Project-URL: Source, https://github.com/fmorton/robot-tasks
Author-email: Frank Morton <fmorton@mac.com>
License-Expression: MIT
License-File: AUTHORS.rst
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Description-Content-Type: text/x-rst

========
Overview
========

.. start-badges

.. list-table::
    :stub-columns: 1

    * - docs
      - |docs|
    * - package
      - | |version| |wheel| |supported-versions|
.. |docs| image:: https://readthedocs.org/projects/robot-tasks/badge/?style=flat
    :target: https://robot-tasks.readthedocs.io/
    :alt: Documentation Status

.. |github-actions| image:: https://github.com/fmorton/robot-tasks/actions/workflows/github-actions.yml/badge.svg
    :alt: GitHub Actions Build Status
    :target: https://github.com/fmorton/robot-tasks/actions

.. |requires| image:: https://requires.io/github/fmorton/robot-tasks/requirements.svg?branch=main
    :alt: Requirements Status
    :target: https://requires.io/github/fmorton/robot-tasks/requirements/?branch=main

.. |codecov| image:: https://codecov.io/gh/fmorton/robot-tasks/branch/main/graphs/badge.svg?branch=main
    :alt: Coverage Status
    :target: https://codecov.io/github/fmorton/robot-tasks

.. |version| image:: https://img.shields.io/pypi/v/robot-tasks.svg
    :alt: PyPI Package latest release
    :target: https://pypi.org/project/robot-tasks

.. |wheel| image:: https://img.shields.io/pypi/wheel/robot-tasks.svg
    :alt: PyPI Wheel
    :target: https://pypi.org/project/robot-tasks

.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/robot-tasks.svg
    :alt: Supported versions
    :target: https://pypi.org/project/robot-tasks

.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/robot-tasks.svg
    :alt: Supported implementations
    :target: https://pypi.org/project/robot-tasks


.. end-badges

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
====================================

.. code-block:: python

  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
========================================

.. code-block:: python

  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
