From 04d0217e0d6b8ba82a23580ccd05c93cde48a866 Mon Sep 17 00:00:00 2001 From: manatlan Date: Sat, 8 Jun 2024 13:16:05 +0000 Subject: [PATCH] shorter comm on fifo --- htagweb/fifo.py | 2 +- htagweb/hrprocess.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htagweb/fifo.py b/htagweb/fifo.py index fcf2d5f..8001858 100644 --- a/htagweb/fifo.py +++ b/htagweb/fifo.py @@ -82,7 +82,7 @@ async def com(self,command:str,**args) -> "str|dict": # for client only try: c = json.loads(frame.strip()) except json.decoder.JSONDecodeError as e: - raise Exception(f"fifo jcom json error '{e}' : '{frame}'") + raise Exception(f"fifo jcom json error '{e}' : >>>{frame.strip()}<<<") if "err" in c: raise Exception(f"com error : {c['err']}") return c["response"] diff --git a/htagweb/hrprocess.py b/htagweb/hrprocess.py index 629b0a0..8f6faaa 100644 --- a/htagweb/hrprocess.py +++ b/htagweb/hrprocess.py @@ -134,23 +134,24 @@ def destroy(): time_activity=time.monotonic() # log("recept command:",frame) - c=json.loads(frame.strip()) + q=json.loads(frame.strip()) + r={} try: - c["response"]=await cmd(**c) + r["response"]=await cmd(**q) except Exception as e: # HRenderer.interact has its own system, but needed for create ;-( if hasattr( sys, "hr") and sys.hr and sys.hr.fullerror: err=traceback.format_exc() else: err=str(e) - c["err"]=err + r["err"]=err # Envoyer la réponse au client - await fifo_out.write(json.dumps(c) + '\n') + await fifo_out.write(json.dumps(r) + '\n') await fifo_out.flush() - if "err" in c: - raise Exception(c["err"]) + if "err" in r: + raise Exception(r["err"]) if timeout_inactivity: # if timeout_inactivity is set if time.monotonic() - time_activity > timeout_inactivity: