diff options
author | ngharo <root@ngha.ro> | 2018-06-28 23:35:32 -0500 |
---|---|---|
committer | ngharo <root@ngha.ro> | 2018-06-28 23:35:32 -0500 |
commit | 49c83f0c693890f1e2df33919606362890bf726d (patch) | |
tree | d792e9ab08ae954ef95ac5cd1719cd3f2ef6c64b /lib | |
parent | df15f0e7aa0e0e7d632e0859f003f547417bf2c2 (diff) | |
download | ansibots-49c83f0c693890f1e2df33919606362890bf726d.tar.xz ansibots-49c83f0c693890f1e2df33919606362890bf726d.zip |
WIP
Diffstat (limited to 'lib')
-rw-r--r-- | lib/__init__.py | 0 | ||||
-rw-r--r-- | lib/worker.py | 23 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/__init__.py diff --git a/lib/worker.py b/lib/worker.py new file mode 100644 index 0000000..a3ee435 --- /dev/null +++ b/lib/worker.py @@ -0,0 +1,23 @@ +import threading +import time + +def name(): + return threading.currentThread().getName() + +def worker(q): + while True: + part = q.get() + + if part is None: + break + + do_work(part) + time.sleep(0.05) + q.task_done() + +def do_work(part: dict): + if part['type'] == "print": + action_print(part['payload']) + +def action_print(text: str): + print('{0} - {1}'.format(name(), text)) |