https://github.com/nibblepoker/template-python-worker-app
Template for a threaded worker-based applications in Python.
https://github.com/nibblepoker/template-python-worker-app
docker python worker-threads
Last synced: 4 months ago
JSON representation
Template for a threaded worker-based applications in Python.
- Host: GitHub
- URL: https://github.com/nibblepoker/template-python-worker-app
- Owner: NibblePoker
- License: cc0-1.0
- Created: 2023-12-16T21:20:12.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-16T22:33:52.000Z (over 1 year ago)
- Last Synced: 2024-12-28T10:44:33.830Z (5 months ago)
- Topics: docker, python, worker-threads
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE-CC0
Awesome Lists containing this project
README
# NibblePoker's Python Worker App Template
Template for a simple threaded worker-based applications in Python.This template has successfully been used internally for "[nibblepoker.lu](https://nibblepoker.lu)" since 2021
and has finally been made public for easier referencing and usage in future projects.The whole demo totals at around 300 LoC and is quite easy to modify.
It can also be taken appart and re-incorporated in other project freely due to the very permissive license.## Customization
### Application's Name
The application's name can be changed in '[app/app.py](app/app.py)', and you just need to adapt the following lines:
```python
# > Printing the logs header
print_header(logger, "My App")
```### Workers
Workers are simple objects that extend a common class and point to a thread's main function.A short example can be found in '[app/my_app/workers/example.py](app/my_app/workers/example.py)'.
If you want to add your own, you just need to edit the following lines in '[app/app.py](app/app.py)' to include your own.
```python
# > Preparing workers.
logger.info("Preparing workers...")
workers: list[Worker] = list()
workers.append(create_example_worker(
config=config,
name_suffix="demo",
sleep_count=5,
sleep_length_ms=750,
))
```## Usage
### Any Host
```shell
cd app/
python ./app.py
```### Docker-compose
```shell
docker-compose up --build -d
```## Licenses
This project is dual-licensed under the following open-source licenses.
You can choose the one that best suits your needs:
1. [MIT License](LICENSE-MIT)
● Just include the `LICENSE-MIT` file and be done with it while using an OSI license.2. [CC0 1.0 Universal (CC0 1.0) (Public Domain)](LICENSE-CC0)
● Do whatever you want with it.
● No credit, mentions or anything else is needed.
● Just have fun programming :)