Skip to content

Commit

Permalink
shorter comm on fifo
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Jun 8, 2024
1 parent 1bc5f45 commit 04d0217
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion htagweb/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
13 changes: 7 additions & 6 deletions htagweb/hrprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 04d0217

Please sign in to comment.