Template for a simple threaded worker-based applications in Python.
This template has successfully been used internally for "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.
The application's name can be changed in 'app/app.py', and you just need to adapt the following lines:
# > Printing the logs header
print_header(logger, "My App")
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'.
If you want to add your own, you just need to edit the following lines in 'app/app.py' to include your own.
# > 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,
))
cd app/
python ./app.py
docker-compose up --build -d
This project is dual-licensed under the following open-source licenses.
You can choose the one that best suits your needs:
-
MIT License
● Just include theLICENSE-MIT
file and be done with it while using an OSI license. -
CC0 1.0 Universal (CC0 1.0) (Public Domain)
● Do whatever you want with it.
● No credit, mentions or anything else is needed.
● Just have fun programming :)