Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Donald 0.32.5 #############
.. _description:
Donald -- A fast and simple tasks manager for Asyncio.
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:
.. _installation:
Donald should be installed using pip: ::
pip install donald
With redis support: ::
pip install donald[redis]
.. _usage:
Init the tasks manager:
.. code:: python
# Init Donald
manager = Donald(
# Params (default values)
# -----------------------
# Setup logging
log_level=logging.INFO,
log_config=None,
# Choose a backend (memory|redis|amqp)
# memory - is only recommended for testing/local development
backend='memory',
# Backend connection params
# redis: {'url': 'redis://localhost:6379/0', 'channel': 'donald'}
# amqp: {'url': 'amqp://guest:guest@localhost:5672/', 'queue': 'donald', 'exchange': 'donald'}
backend_params={},
# Tasks worker params
worker_params={
# Max tasks in work
'max_tasks': 0,
# Tasks default params (delay, timeout)
'task_defaults': {},
# A awaitable function to run on worker start
'on_start': None
# A awaitable function to run on worker stop
'on_stop': None
# A awaitable function to run on worker error
'on_error': None
},
)
# Wrap a function to task
@manager.task
async def myfunc(*args, **kwargs):
# Do some job here
# Start the manager somewhere (on app start for example)
await manager.start()
# you may run a worker in the same process
# not recommended for production
worker = manager.create_worker()
worker.start()
# ...
# Submit the task to workers
myfunc.submit(*args, **kwargs)
# ...
# Stop the manager when you need
await worker.stop()
await manager.stop()
.. code:: python
@tasks.schedule('*/5 * * * *') # Supports cron expressions, number of seconds, timedelta @tasks.task async def myfunc(*args, **kwargs): """Run every 5 minutes""" # Do some job here
manager.scheduler.start()
manager.scheduler.stop()
Create a tasks manager somewhere in your app tasks.py
:
.. code:: python
manager = Donald(backend='amqp')
Run a worker in a separate process:
.. code:: bash
$ donald -M tasks.manager worker
Run a scheduler (if you need) in a separate process:
.. code:: bash
$ donald -M tasks.manager scheduler
.. _bugtracker:
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/donald/issues
.. _contributing:
Development of starter happens at github: https://github.com/klen/donald
.. _license:
Licensed under a MIT license
_.
.. _links:
.. _MIT license: http://opensource.org/licenses/MIT .. _klen: https://klen.github.io/
FAQs
Task manager for asyncio
We found that donald demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.