# Sanic Scheduler
Sanic Scheduler runs a functions on a schedule.
## Installation
Automatic installation:
```bash
$ pip install sanic-scheduler
```
Sanic Scheduler is listed in [PyPI](https://pypi.python.org/pypi/sanic-scheduler) and can be installed with pip or easy_install.
Manual installation:
```bash
$ git clone https://github.com/asmodius/sanic-scheduler.git
$ cd sanic_scheduler
$ python setup.py install
```
Sanic Scheduler source code is [hosted on GitHub](https://github.com/asmodius/sanic-scheduler)
## Usage
```python
import asyncio
from datetime import datetime, time, timedelta
from sanic import Sanic
from sanic_scheduler import SanicScheduler, task
app = Sanic()
scheduler = SanicScheduler(app)
@task(timedelta(seconds=30))
def hello(app):
"""Runs the function every 30 seconds."""
print("Hello, {0}".format(app), datetime.now())
@task(timedelta(hours=1), time(hour=1, minute=30))
async def foo_bar(_):
"""Runs the function every 1 hours after 1:30."""
print("Foo", datetime.now())
await asyncio.sleep(1)
print("Bar")
@task(timedelta(minutes=2), timedelta(seconds=10))
def baz(_):
"""Runs the function every 2 minutes after 10 seconds."""
print("Baz", datetime.now())
@task(start=timedelta(seconds=10))
def another(_):
"""Run the function after 10 seconds once."""
print("another", datetime.now())
if __name__ == "__main__":
app.run(host='127.0.0.1', port=5000, debug=True)
```
Sanic Scheduler runs a functions on a schedule.
## Installation
Automatic installation:
```bash
$ pip install sanic-scheduler
```
Sanic Scheduler is listed in [PyPI](https://pypi.python.org/pypi/sanic-scheduler) and can be installed with pip or easy_install.
Manual installation:
```bash
$ git clone https://github.com/asmodius/sanic-scheduler.git
$ cd sanic_scheduler
$ python setup.py install
```
Sanic Scheduler source code is [hosted on GitHub](https://github.com/asmodius/sanic-scheduler)
## Usage
```python
import asyncio
from datetime import datetime, time, timedelta
from sanic import Sanic
from sanic_scheduler import SanicScheduler, task
app = Sanic()
scheduler = SanicScheduler(app)
@task(timedelta(seconds=30))
def hello(app):
"""Runs the function every 30 seconds."""
print("Hello, {0}".format(app), datetime.now())
@task(timedelta(hours=1), time(hour=1, minute=30))
async def foo_bar(_):
"""Runs the function every 1 hours after 1:30."""
print("Foo", datetime.now())
await asyncio.sleep(1)
print("Bar")
@task(timedelta(minutes=2), timedelta(seconds=10))
def baz(_):
"""Runs the function every 2 minutes after 10 seconds."""
print("Baz", datetime.now())
@task(start=timedelta(seconds=10))
def another(_):
"""Run the function after 10 seconds once."""
print("another", datetime.now())
if __name__ == "__main__":
app.run(host='127.0.0.1', port=5000, debug=True)
```
Metadata
Release files for sanic-scheduler 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sanic-scheduler-1.0.7.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sanic_scheduler-1.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.8 kB
Release files / sanic-scheduler-1.0.7.tar.gz
| Download URL | sanic-scheduler-1.0.7.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46dad9a43ba745bda47eb8bf45f92eb60906010e1877b60d1652e99914bd3ed1
|
|
BLAKE2b-256 checksum How to use checksums |
216eb31af4ff1375906a78b80b1ac170ff40d87ed6e353bf55b975c804948187
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Release files / sanic_scheduler-1.0.7-py3-none-any.whl
| Download URL | sanic_scheduler-1.0.7-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
416cfd7ea3b53338c8a3a0011b0a9f8127f81eb3acebb038b1bee96c12346e77
|
|
BLAKE2b-256 checksum How to use checksums |
8dcf7829255feb914da028eefa42581c357f2559ad1c808d33809470340d5edc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|