diff --git a/htagweb/fifo.py b/htagweb/fifo.py index 4757b4e..fcf2d5f 100644 --- a/htagweb/fifo.py +++ b/htagweb/fifo.py @@ -79,7 +79,10 @@ async def com(self,command:str,**args) -> "str|dict": # for client only frame = await fifo_in.readline() #print("Client receive:",frame) - c = json.loads(frame.strip()) + try: + c = json.loads(frame.strip()) + except json.decoder.JSONDecodeError as e: + raise Exception(f"fifo jcom json error '{e}' : '{frame}'") if "err" in c: raise Exception(f"com error : {c['err']}") return c["response"] diff --git a/htagweb/runners.py b/htagweb/runners.py index ace1a93..85cf163 100644 --- a/htagweb/runners.py +++ b/htagweb/runners.py @@ -11,6 +11,7 @@ #from shared_memory_dict import SharedMemoryDict +import contextlib import asyncio import os,sys import sys @@ -179,6 +180,7 @@ async def on_disconnect(self, websocket, close_code): # NO WAIT the cancellation of the task !!!!!! +@contextlib.asynccontextmanager async def lifespan(app): print("--- START") await HrClient.clean() @@ -186,6 +188,7 @@ async def lifespan(app): print("--- STOP") await HrClient.clean() + class Runner(Starlette): def __init__(self, obj:"Tag|fqn|None"=None,