Skip to content

Commit

Permalink
fix lifespan & fifo json decode
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Jun 8, 2024
1 parent 954d82c commit 1bc5f45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion htagweb/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
3 changes: 3 additions & 0 deletions htagweb/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#from shared_memory_dict import SharedMemoryDict

import contextlib
import asyncio
import os,sys
import sys
Expand Down Expand Up @@ -179,13 +180,15 @@ 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()
yield
print("--- STOP")
await HrClient.clean()


class Runner(Starlette):
def __init__(self,
obj:"Tag|fqn|None"=None,
Expand Down

0 comments on commit 1bc5f45

Please sign in to comment.