Async shit

This commit is contained in:
Maximilian Giller 2023-10-11 01:45:17 +02:00
parent d58f37b679
commit 6bf7f7525e

View file

@ -36,7 +36,7 @@ async def start_time_loop():
async def turn_off(): async def turn_off():
global should_run_time_loop global should_run_time_loop
should_run_time_loop = False should_run_time_loop = False
matrix_display.turn_off() asyncio.create_task(lambda: matrix_display.turn_off())
return {"message": "Display turned off"} return {"message": "Display turned off"}
@ -44,7 +44,7 @@ async def turn_off():
async def flash(count: int = 1): async def flash(count: int = 1):
global should_run_time_loop global should_run_time_loop
should_run_time_loop = False should_run_time_loop = False
matrix_display.flash(count) asyncio.create_task(lambda: matrix_display.flash(count))
return {"message": "Display flashed"} return {"message": "Display flashed"}
@ -54,7 +54,7 @@ async def display_message(body: dict):
should_run_time_loop = False should_run_time_loop = False
message_text = body.get("message") message_text = body.get("message")
try: try:
matrix_display.show_text(message_text) asyncio.create_task(lambda: matrix_display.show_text(message_text))
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
raise HTTPException( raise HTTPException(
status_code=500, status_code=500,