asyncz


Nameasyncz JSON
Version 0.12.0 PyPI version JSON
download
home_pageNone
SummaryThe scheduler that nobody wants but every application needs.
upload_time2024-10-09 07:03:23
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords apscheduler asgi asyncz cron fastapi framework pydantic scheduler starlette
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Asyncz

<p align="center">
  <a href="https://asyncz.tarsil.io"><img src="https://res.cloudinary.com/tarsild/image/upload/v1687363326/packages/asyncz/asyncz-new_wiyih8.png" alt='Asyncz'></a>
</p>

<p align="center">
    <em>🚀 The scheduler that simply works. 🚀</em>
</p>

<p align="center">
<a href="https://github.com/dymmond/asyncz/workflows/Test%20Suite/badge.svg?event=push&branch=main" target="_blank">
    <img src="https://github.com/dymmond/asyncz/workflows/Test%20Suite/badge.svg?event=push&branch=main" alt="Test Suite">
</a>

<a href="https://pypi.org/project/asyncz" target="_blank">
    <img src="https://img.shields.io/pypi/v/asyncz?color=%2334D058&label=pypi%20package" alt="Package version">
</a>

<a href="https://pypi.org/project/asyncz" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/asyncz.svg?color=%2334D058" alt="Supported Python versions">
</a>
</p>

---

**Documentation**: [https://asyncz.dymmond.com](https://asyncz.dymmond.com) 📚

**Source Code**: [https://github.com/dymmond/asyncz](https://github.com/dymmond/asyncz)

---

Asyncz is a scheduler for any ASGI application that needs to have those complicated scheduled operations with the
best of what pydantic can offer.

## Motivation

Nowadays using async frameworks with python is somewhat common and becoming even more mainstream. A lot of applications
usually need a complex stack of technologies to fullfil their needs and directly or indirectly, a scheduler.

There are great frameworks out there that do the task extremely well, the best example is APScheduler, which is where
Asyncz came from.

To be even more honest, Asyncz is a revamp of APScheduler. Without the APScheduler there is no Asyncz, so much that
even the APScheduler tests are used within asyncz. That is how great APScheduler is!

So what was the reason why recreating another similar version of APScheduler? Well, it is not entirely the same
thing. Asyncz was designed to work only with ASGI and AsyncIO as well as integrating pydantic and bring the modern
python into the table.

APScheduler is widely used by millions of python developers and Asyncz **does not aim to replace** it, instead
is a more focused and optimised solution for async and ASGI frameworks out there.

See the [vendors](./vendors/apscheduler/README.md) for more details.

## Logging

We all struggle with the logging and the configurations and with that in mind Asyncz comes with natice support
for loguru.

This will make the logging a lot easier to understand and clear to read.

## Async and ASGI

What does this mean? Well, Asyncz does not need to run inside any specific framework, actually you can use it
completely indepent from any framework as well as inside ASGI frameworks such as
[Esmerald](https://esmerald.dymmond.com), FastAPI, Starlette, Starlite, Quart... You can pick one and go for it.

Asyncz comes with special support to [Esmerald](https://esmerald.dymmond.com) for the simple reason that the author is
the same but it can be added more support. If you are interested in adding support to your favourite frameworks then
see the [contributing](https://asyncz.dymmond.com/contributing.md) section.

## Concepts

Like APScheduler, Asyncz also brings four kinds of components:

* [Schedulers](https://asyncz.dymmond.com/schedulers.md)
* [Triggers](https://asyncz.dymmond.com/triggers.md)
* [Stores](https://asyncz.dymmond.com/stores.md)
* [Executors](https://asyncz.dymmond.com/executors.md)

## Requirements

* Python 3.7+

Asyncz wouldn't be possible without two giants:

* <a href="https://apscheduler.readthedocs.io/en/3.x/" class="external-link" target="_blank">APScheduler</a>
* <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a>

## Installation

```shell
$ pip install asyncz
```

## The right decisions

How do you know if you are choosing the right [scheduler](https://asyncz.dymmond.com/schedulers.md),
[triggers](https://asyncz.dymmond.com/triggers.md), [stores](https://asyncz.dymmond.com/stores.md)
and [executors](https://asyncz.dymmond.com/executors.md)?

Well, Asyncz is intentionally designed for specific systems and already helps you out with some of
those questions.

* **Schedulers** - Natively only supports the [AsyncIOScheduler](https://asyncz.dymmond.com/schedulers.md#asyncioscheduler).
* **Triggers** - Here it will depend of the periocidity of our tasks. Example:
    * [CronTrigger](https://asyncz.dymmond.com/triggers.md#crontrigger) - UNIX like cron and gives you the same feeling as
scheduling a task on a native UNIX like based system.
    * [DateTrigger](https://asyncz.dymmond.com/triggers.md#datetrigger) - When you need to run a task once on a specific
point of time.
    * [IntervalTrigger](https://asyncz.dymmond.com/triggers.md#intervaltrigger) - When you need to run tasks in specific
intervals of time.
    * [OrTrigger](https://asyncz.dymmond.com/triggers.md#ortrigger)/[AndTrigger](https://asyncz.dymmond.com/triggers.md#andtrigger) - If you would
like to combine more than one trigger (cron, interval and date) together.
* **Stores** - Natively only supports [redis](https://asyncz.dymmond.com/stores.md#redisstore),
[mongo](https://asyncz.dymmond.com/stores.md#mongodbstore) and [memory](https://asyncz.dymmond.com/stores.md#memorystore).
* **Executors** - Natively only supports [AsyncIOExecutor](https://asyncz.dymmond.com/executors.md#asyncioexecutor),
[ThreadPoolExecutor](https://asyncz.dymmond.com/executors.md#threadpoolexecutor) and
[ProcessPoolExecutor](https://asyncz.dymmond.com/executors.md#processpoolexecutor).

Sometimes having a lot of options makes the decision making very hard and Asyncz is intentionally
designed and driven to simplify and for specific use cases but is not limited to those. In every
section you have the option of uilding your own stores, executors, triggers and schedulers.

## Configuring the scheduler

Due its simplificy, Asyncz provides some ways of configuring the scheduler for you.

First way:

```python
from asyncz.schedulers.asyncio import AsyncIOScheduler

scheduler = AsyncIOScheduler()
```

Second way:

```python
from asyncz.schedulers import AsyncIOScheduler

scheduler = AsyncIOScheduler()
```

Initialize the rest of the application after the `scheduler` initialisation.
More [details](https://asyncz.dymmond.com/schedulers.md) can be found with more thorough explanations.

This is in simple terms and in a nutshell how to start with Asyncz quickly. For more information,
details and examples how to leverage Asyncz simply navigate through the documentation and have
fun 😁🎉.

## ASGI support

Asyncz currently supports ASGI, the [Esmerald framework](https://asyncz.dymmond.com/contrib/esmerald/)
and brings some batteries that are currently used by Esmerald and leveraging Asyncz.


```python
from asyncz.schedulers import AsyncIOScheduler
...

# handle_lifespan is optional, set to True if you don't want to pass it down because the underlying app doesn't support it
# this is true for django
application = AsyncIOScheduler().asgi(application, handle_lifespan=False)
# or more simple (please do not use both together)
application = AsyncIOScheduler().asgi()(application)
```

Using with lilya:

```python
from asyncz.schedulers import AsyncIOScheduler

# Lilya middleware doesn't pass lifespan events

app = AsyncIOScheduler().asgi(Lilya(
    routes=[...],
))

```

Or manually:

```python
from asyncz.schedulers import AsyncIOScheduler

scheduler = AsyncIOScheduler()

app = Lilya(
    routes=[...],
    on_startup=[scheduler.start],
    on_shutdown=[scheduler.shutdown],
)

```


## Contextmanager support

Use as sync contextmanager

```python
from asyncz.schedulers import AsyncIOScheduler

with AsyncIOScheduler() as scheduler:
    ...
```

Use as async contextmanager

```python
from asyncz.schedulers import AsyncIOScheduler

async with AsyncIOScheduler() as scheduler:
    ...
```

For using with lifespan of starlette:

```python
from asyncz.schedulers import AsyncIOScheduler

async lifespan(app):
    with AsyncIOScheduler() as scheduler:
        yield
        # or yield a state
app = Starlette(
    lifespan=lifespan,
)

```

## Security

You should use store encryption for security reasons.

All standard stores except MemoryStore support the environment variable `ASYNCZ_STORE_ENCRYPTION_KEY`.
If set and non-empty the hash of the value is used for AESGCM encrypting the elements before sending them
to the store.
This way store entries are encrypted and authentificated so there is no security hole.
This is highly recommended! Because if someone can inject store entries he can execute code.

## Sponsors

Currently there are no sponsors of **Asyncz** but you can financially help and support the author though
[GitHub sponsors](https://github.com/sponsors/tarsil) and become a **Special one** or a **Legend**.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "asyncz",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "apscheduler, asgi, asyncz, cron, fastapi, framework, pydantic, scheduler, starlette",
    "author": null,
    "author_email": "Tiago Silva <tiago.arasilva@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4a/af/0fd9853a0d3e36aa575b98eb22395f143f0ddafe6a87ea3dc891ced2e755/asyncz-0.12.0.tar.gz",
    "platform": null,
    "description": "# Asyncz\n\n<p align=\"center\">\n  <a href=\"https://asyncz.tarsil.io\"><img src=\"https://res.cloudinary.com/tarsild/image/upload/v1687363326/packages/asyncz/asyncz-new_wiyih8.png\" alt='Asyncz'></a>\n</p>\n\n<p align=\"center\">\n    <em>\ud83d\ude80 The scheduler that simply works. \ud83d\ude80</em>\n</p>\n\n<p align=\"center\">\n<a href=\"https://github.com/dymmond/asyncz/workflows/Test%20Suite/badge.svg?event=push&branch=main\" target=\"_blank\">\n    <img src=\"https://github.com/dymmond/asyncz/workflows/Test%20Suite/badge.svg?event=push&branch=main\" alt=\"Test Suite\">\n</a>\n\n<a href=\"https://pypi.org/project/asyncz\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/v/asyncz?color=%2334D058&label=pypi%20package\" alt=\"Package version\">\n</a>\n\n<a href=\"https://pypi.org/project/asyncz\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/pyversions/asyncz.svg?color=%2334D058\" alt=\"Supported Python versions\">\n</a>\n</p>\n\n---\n\n**Documentation**: [https://asyncz.dymmond.com](https://asyncz.dymmond.com) \ud83d\udcda\n\n**Source Code**: [https://github.com/dymmond/asyncz](https://github.com/dymmond/asyncz)\n\n---\n\nAsyncz is a scheduler for any ASGI application that needs to have those complicated scheduled operations with the\nbest of what pydantic can offer.\n\n## Motivation\n\nNowadays using async frameworks with python is somewhat common and becoming even more mainstream. A lot of applications\nusually need a complex stack of technologies to fullfil their needs and directly or indirectly, a scheduler.\n\nThere are great frameworks out there that do the task extremely well, the best example is APScheduler, which is where\nAsyncz came from.\n\nTo be even more honest, Asyncz is a revamp of APScheduler. Without the APScheduler there is no Asyncz, so much that\neven the APScheduler tests are used within asyncz. That is how great APScheduler is!\n\nSo what was the reason why recreating another similar version of APScheduler? Well, it is not entirely the same\nthing. Asyncz was designed to work only with ASGI and AsyncIO as well as integrating pydantic and bring the modern\npython into the table.\n\nAPScheduler is widely used by millions of python developers and Asyncz **does not aim to replace** it, instead\nis a more focused and optimised solution for async and ASGI frameworks out there.\n\nSee the [vendors](./vendors/apscheduler/README.md) for more details.\n\n## Logging\n\nWe all struggle with the logging and the configurations and with that in mind Asyncz comes with natice support\nfor loguru.\n\nThis will make the logging a lot easier to understand and clear to read.\n\n## Async and ASGI\n\nWhat does this mean? Well, Asyncz does not need to run inside any specific framework, actually you can use it\ncompletely indepent from any framework as well as inside ASGI frameworks such as\n[Esmerald](https://esmerald.dymmond.com), FastAPI, Starlette, Starlite, Quart... You can pick one and go for it.\n\nAsyncz comes with special support to [Esmerald](https://esmerald.dymmond.com) for the simple reason that the author is\nthe same but it can be added more support. If you are interested in adding support to your favourite frameworks then\nsee the [contributing](https://asyncz.dymmond.com/contributing.md) section.\n\n## Concepts\n\nLike APScheduler, Asyncz also brings four kinds of components:\n\n* [Schedulers](https://asyncz.dymmond.com/schedulers.md)\n* [Triggers](https://asyncz.dymmond.com/triggers.md)\n* [Stores](https://asyncz.dymmond.com/stores.md)\n* [Executors](https://asyncz.dymmond.com/executors.md)\n\n## Requirements\n\n* Python 3.7+\n\nAsyncz wouldn't be possible without two giants:\n\n* <a href=\"https://apscheduler.readthedocs.io/en/3.x/\" class=\"external-link\" target=\"_blank\">APScheduler</a>\n* <a href=\"https://pydantic-docs.helpmanual.io/\" class=\"external-link\" target=\"_blank\">Pydantic</a>\n\n## Installation\n\n```shell\n$ pip install asyncz\n```\n\n## The right decisions\n\nHow do you know if you are choosing the right [scheduler](https://asyncz.dymmond.com/schedulers.md),\n[triggers](https://asyncz.dymmond.com/triggers.md), [stores](https://asyncz.dymmond.com/stores.md)\nand [executors](https://asyncz.dymmond.com/executors.md)?\n\nWell, Asyncz is intentionally designed for specific systems and already helps you out with some of\nthose questions.\n\n* **Schedulers** - Natively only supports the [AsyncIOScheduler](https://asyncz.dymmond.com/schedulers.md#asyncioscheduler).\n* **Triggers** - Here it will depend of the periocidity of our tasks. Example:\n    * [CronTrigger](https://asyncz.dymmond.com/triggers.md#crontrigger) - UNIX like cron and gives you the same feeling as\nscheduling a task on a native UNIX like based system.\n    * [DateTrigger](https://asyncz.dymmond.com/triggers.md#datetrigger) - When you need to run a task once on a specific\npoint of time.\n    * [IntervalTrigger](https://asyncz.dymmond.com/triggers.md#intervaltrigger) - When you need to run tasks in specific\nintervals of time.\n    * [OrTrigger](https://asyncz.dymmond.com/triggers.md#ortrigger)/[AndTrigger](https://asyncz.dymmond.com/triggers.md#andtrigger) - If you would\nlike to combine more than one trigger (cron, interval and date) together.\n* **Stores** - Natively only supports [redis](https://asyncz.dymmond.com/stores.md#redisstore),\n[mongo](https://asyncz.dymmond.com/stores.md#mongodbstore) and [memory](https://asyncz.dymmond.com/stores.md#memorystore).\n* **Executors** - Natively only supports [AsyncIOExecutor](https://asyncz.dymmond.com/executors.md#asyncioexecutor),\n[ThreadPoolExecutor](https://asyncz.dymmond.com/executors.md#threadpoolexecutor) and\n[ProcessPoolExecutor](https://asyncz.dymmond.com/executors.md#processpoolexecutor).\n\nSometimes having a lot of options makes the decision making very hard and Asyncz is intentionally\ndesigned and driven to simplify and for specific use cases but is not limited to those. In every\nsection you have the option of uilding your own stores, executors, triggers and schedulers.\n\n## Configuring the scheduler\n\nDue its simplificy, Asyncz provides some ways of configuring the scheduler for you.\n\nFirst way:\n\n```python\nfrom asyncz.schedulers.asyncio import AsyncIOScheduler\n\nscheduler = AsyncIOScheduler()\n```\n\nSecond way:\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n\nscheduler = AsyncIOScheduler()\n```\n\nInitialize the rest of the application after the `scheduler` initialisation.\nMore [details](https://asyncz.dymmond.com/schedulers.md) can be found with more thorough explanations.\n\nThis is in simple terms and in a nutshell how to start with Asyncz quickly. For more information,\ndetails and examples how to leverage Asyncz simply navigate through the documentation and have\nfun \ud83d\ude01\ud83c\udf89.\n\n## ASGI support\n\nAsyncz currently supports ASGI, the [Esmerald framework](https://asyncz.dymmond.com/contrib/esmerald/)\nand brings some batteries that are currently used by Esmerald and leveraging Asyncz.\n\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n...\n\n# handle_lifespan is optional, set to True if you don't want to pass it down because the underlying app doesn't support it\n# this is true for django\napplication = AsyncIOScheduler().asgi(application, handle_lifespan=False)\n# or more simple (please do not use both together)\napplication = AsyncIOScheduler().asgi()(application)\n```\n\nUsing with lilya:\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n\n# Lilya middleware doesn't pass lifespan events\n\napp = AsyncIOScheduler().asgi(Lilya(\n    routes=[...],\n))\n\n```\n\nOr manually:\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n\nscheduler = AsyncIOScheduler()\n\napp = Lilya(\n    routes=[...],\n    on_startup=[scheduler.start],\n    on_shutdown=[scheduler.shutdown],\n)\n\n```\n\n\n## Contextmanager support\n\nUse as sync contextmanager\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n\nwith AsyncIOScheduler() as scheduler:\n    ...\n```\n\nUse as async contextmanager\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n\nasync with AsyncIOScheduler() as scheduler:\n    ...\n```\n\nFor using with lifespan of starlette:\n\n```python\nfrom asyncz.schedulers import AsyncIOScheduler\n\nasync lifespan(app):\n    with AsyncIOScheduler() as scheduler:\n        yield\n        # or yield a state\napp = Starlette(\n    lifespan=lifespan,\n)\n\n```\n\n## Security\n\nYou should use store encryption for security reasons.\n\nAll standard stores except MemoryStore support the environment variable `ASYNCZ_STORE_ENCRYPTION_KEY`.\nIf set and non-empty the hash of the value is used for AESGCM encrypting the elements before sending them\nto the store.\nThis way store entries are encrypted and authentificated so there is no security hole.\nThis is highly recommended! Because if someone can inject store entries he can execute code.\n\n## Sponsors\n\nCurrently there are no sponsors of **Asyncz** but you can financially help and support the author though\n[GitHub sponsors](https://github.com/sponsors/tarsil) and become a **Special one** or a **Legend**.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "The scheduler that nobody wants but every application needs.",
    "version": "0.12.0",
    "project_urls": {
        "Changelog": "https://asyncz.dymmond.com/release-notes/",
        "Documentation": "https://asyncz.dymmond.com/",
        "Funding": "https://github.com/sponsors/tarsil",
        "Homepage": "https://github.com/dymmond/asyncz",
        "Source": "https://github.com/dymmond/asyncz"
    },
    "split_keywords": [
        "apscheduler",
        " asgi",
        " asyncz",
        " cron",
        " fastapi",
        " framework",
        " pydantic",
        " scheduler",
        " starlette"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "21fddb3827d019d65b7562f1ab3a40a9f53f3f81dd84fdf936afeaba108643b9",
                "md5": "9479c5642e87a7ab04078f2bc8b74bdf",
                "sha256": "0fcf4d94ca23242765e26d601437406e645fa6d446d7830a9022dec66b5ada35"
            },
            "downloads": -1,
            "filename": "asyncz-0.12.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9479c5642e87a7ab04078f2bc8b74bdf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 65203,
            "upload_time": "2024-10-09T07:03:22",
            "upload_time_iso_8601": "2024-10-09T07:03:22.381358Z",
            "url": "https://files.pythonhosted.org/packages/21/fd/db3827d019d65b7562f1ab3a40a9f53f3f81dd84fdf936afeaba108643b9/asyncz-0.12.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4aaf0fd9853a0d3e36aa575b98eb22395f143f0ddafe6a87ea3dc891ced2e755",
                "md5": "6e5bc6e41e2ed88c38bada1b1db74639",
                "sha256": "9260dac26d9d310e0ee473629b48e3dab7571d310b468ac5e3bb06daa16b8063"
            },
            "downloads": -1,
            "filename": "asyncz-0.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6e5bc6e41e2ed88c38bada1b1db74639",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 45621,
            "upload_time": "2024-10-09T07:03:23",
            "upload_time_iso_8601": "2024-10-09T07:03:23.964519Z",
            "url": "https://files.pythonhosted.org/packages/4a/af/0fd9853a0d3e36aa575b98eb22395f143f0ddafe6a87ea3dc891ced2e755/asyncz-0.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-09 07:03:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sponsors",
    "github_project": "tarsil",
    "github_not_found": true,
    "lcname": "asyncz"
}
        
Elapsed time: 1.73683s