Lightweight framework for executing periodic async and sync jobs in python
Project description
regta
Lightweight framework for executing periodic async and sync jobs in python.
Installation
Install using pip install regta
or poetry add regta
.
You can check if regta was installed correctly with the following command
regta --version
, the correct output would be approximately regta, version 0.1.0
.
Samples
To automatically create basic job use regta new
command.
You can specify the job type [async|thread|process]
.
You can always see other options by using the --help
flag.
$ regta new some-async-job --type async
> Async job SomeAsyncJob have been created at jobs/some_async_job.py.
The previous command will create about this kind of code in jobs/some_async_job.py
:
from datetime import timedelta
from regta import AsyncJob
class SomeAsyncJob(AsyncJob):
INTERVAL = timedelta(seconds=3)
async def execute(self): # function is called every 3 seconds
return (
f"Hello from {self.__class__.__name__}! "
f"This message is displayed every {self.INTERVAL.seconds} seconds."
)
To show the jobs list use regta list
command:
$ regta list
> [1] jobs were found at ./:
> * jobs.some_async_job:SomeAsyncJob
To start regta and all jobs use regta run
command:
$ regta run
> [1] jobs were found.
> jobs.some_async_job:SomeAsyncJob - Hello from SomeAsyncJob! this message is displayed every 3 seconds. # code of job
. . .
If you do not want to use the provided OOP, and you would like to easily reuse functions you have already written, you can simply describe them as a list:
# jobs/main.py
def your_function(name):
print(f"Hello, {name}!")
TASKS = [
{
"thread": your_function,
"kwargs": {"name": "User"},
"interval": {
"minutes": 5,
},
},
]
...and pass them to the regta run
command as --list
param:
$ regta run --list jobs.main:TASKS
> [1] jobs were found.
> Hello, User! # code of job
. . .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file regta-0.1.0a0.tar.gz
.
File metadata
- Download URL: regta-0.1.0a0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.7.9 Darwin/19.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15bf5822876d2e96bdd3ce49b1afca692453e6678917c736ce6579755a2ae684 |
|
MD5 | 5c601b03030072c13a159bb327a62003 |
|
BLAKE2b-256 | 1a13285c5cf5ee1a4592d36582cf749168629c07c04a059bd03ca9fb9f5e2083 |
File details
Details for the file regta-0.1.0a0-py3-none-any.whl
.
File metadata
- Download URL: regta-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.7.9 Darwin/19.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d0771e4f7236736db44e6c53d41b258bc83ae5ee909281253cdcfced41a0771 |
|
MD5 | 39e00cdd66b74de560fc4c93385f65d5 |
|
BLAKE2b-256 | 4cd9607d506f45f0ca7632ece329689406f6cfdfce127cf586752a9ecc08a95b |