From 5ebfa034bf5a613d83f7f5819fe0b85c974045ce Mon Sep 17 00:00:00 2001 From: Marco Verleun Date: Sun, 18 Feb 2024 11:53:40 +0100 Subject: [PATCH] Add more --- slides/sbom/python-app-deployment.md | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 slides/sbom/python-app-deployment.md diff --git a/slides/sbom/python-app-deployment.md b/slides/sbom/python-app-deployment.md new file mode 100644 index 0000000..1a14357 --- /dev/null +++ b/slides/sbom/python-app-deployment.md @@ -0,0 +1,42 @@ + +# Back to our app: worker.py + +Let's follow our app from code to deployment in a container. + +During each step we'll analyze the software and show some highlights. + +--- + +Step 1: The code + +```python +import logging +import os +from redis import Redis +import requests +import time +... +redis = Redis("redis") +... +def work_loop(interval=1): + deadline = 0 + loops_done = 0 + while True: + if time.time() > deadline: + log.info("{} units of work done, updating hash counter" + .format(loops_done)) + redis.incrby("hashes", loops_done) + loops_done = 0 + deadline = time.time() + interval + work_once() + loops_done += 1 + +if __name__ == "__main__": + while True: + try: + work_loop() + except: + log.exception("In work loop:") + log.error("Waiting 10s and restarting.") + time.sleep(10) +```