Metadata-Version: 2.1
Name: donald
Version: 0.13.0
Summary: Donald is here
Home-page: https://github.com/klen/donald
Author: Kirill Klenov
Author-email: horneds@gmail.com
License: MIT
Project-URL: Documentation, https://klen.github.io/donald
Project-URL: Source code, https://github.com/klen/donald
Project-URL: Issue tracker, https://github.com/klen/donald/issues
Keywords: asyncio,tasks,queue
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Framework :: AsyncIO
Requires-Python: >=3.7
Provides-Extra: tests
Provides-Extra: build

Donald
######

.. _description:

Donald -- A simple task engine for Asyncio.

The main goal for Donald to run async/sync code without blocking main loop.

Donald supports synchronous and asynchronous paradigms. The package is running
coroutines and functions in multi loops. Donald could run periodic tasks and
listen AMQP queues.

.. _badges:

.. image:: https://github.com/klen/donald/workflows/tests/badge.svg
    :target: https://github.com/klen/donald/actions
    :alt: Tests Status

.. image:: https://img.shields.io/pypi/v/donald
    :target: https://pypi.org/project/donald/
    :alt: PYPI Version

.. image:: https://img.shields.io/pypi/pyversions/donald
    :target: https://pypi.org/project/donald/
    :alt: Python Versions

.. _contents:

.. contents::

.. _requirements:

Requirements
=============

- python 3.7+

.. _installation:

Installation
=============

**Donald** should be installed using pip: ::

    pip install donald

.. _usage:

Usage
=====

From shell: ::

    $ donald --help


From asynchronous python code:

.. code:: python

    # Init Donald
    donald = Donald(
        # Params (default values)
        # -----------------------

        # Run tasks imediatelly in the same process/thread
        fake_mode=False,

        # Number of workers
        num_workers=multiprocessing.cpu_count() - 1,

        # Maximum concurent tasks per worker
        max_tasks_per_worker=100,

        # Ensure that the Donald starts only once (set to filename to lock)
        filelock=None,

        # logging level
        loglevel='INFO',

        # AMQP params
        queue=False,
        queue_name='donald',
        queue_params={},
    )

    # Schedule periodic tasks
    @donald.schedule(crontab_string | seconds_float | datetime_timedelta, *args, **kwargs)
    async def task(*args, **kwargs):
        # ...

    # Start the donald
    await donald.start()

    # ...

    # Submit a task to donald
    donald.submit(corofunction or function, *args, **kwargs)

    # Submit and wait for result
    result = await donald.submit(corofunction or function, *args, **kwargs)

    # Submit a task to queue
    queue.submit(corofunction or function, *args, **kwargs)
    await donald.queue.submit(corofunction or function, *args, **kwargs)

    # note: queue dont support waiting for results

    # ...

    # Stop the donald
    await donald.stop()

Connect and receive tasks using AMQP
------------------------------------

.. code:: python

    donald = Donald()

    await donald.start()
    await donald.queue.start()

    # ...


    # Stop the donald
    await donald.queue.stop()
    await donald.stop()

Submit tasks to AMQP
--------------------

.. code::

    # Send task to queue
    await donald.queue.submit(<coro or func>, *args, **kwargs)

    # ...


.. _bugtracker:

Bug tracker
===========

If you have any suggestions, bug reports or
annoyances please report them to the issue tracker
at https://github.com/klen/donald/issues

.. _contributing:

Contributing
============

Development of starter happens at github: https://github.com/klen/donald


Contributors
=============

* klen_ (Kirill Klenov)

.. _license:

License
========

Licensed under a `BSD license`_.

.. _links:

.. _BSD license: http://www.linfo.org/bsdlicense.html
.. _klen: https://klen.github.io/


