feat: split camera worker and tick worker

This commit is contained in:
2020-08-28 13:39:21 +02:00
parent 955ceb9977
commit 44cb97b44e
2 changed files with 29 additions and 10 deletions

28
cameraworker.py Normal file
View File

@@ -0,0 +1,28 @@
import sched
from redis import Redis
from control.camera import Camera
INTERVAL_TICK = 0.0125 # 20/s
INTERVAL_IMAGE = 0.05 # 20/s
scheduler = sched.scheduler()
camera = Camera()
def camera_image():
scheduler.enter(INTERVAL_IMAGE, 1, camera_image)
image = camera.get_image()
redisdb.publish('image', image)
scheduler.enter(INTERVAL_IMAGE, 1, camera_image)
if __name__ == '__main__':
redisdb = Redis()
try:
scheduler.run()
except KeyboardInterrupt:
raise