Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Oct 14, 2023
1 parent d2cc749 commit 5f15a96
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,9 @@ async def serve(req):
#~ logging.basicConfig(format='[%(levelname)-5s] %(name)s: %(message)s',level=logging.DEBUG)
#~ logging.getLogger("redys.servone").setLevel( logging.INFO )

# or with gunicorn :
#> gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b localhost:8000 example:app
# or with uvicorn :
#> uvicorn example:app --workers 4

app.run(openBrowser=True)
5 changes: 5 additions & 0 deletions htagweb/appserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ async def on_receive(self, websocket, data):

async def on_disconnect(self, websocket, close_code):
self.task.cancel()
try:
await self.task
except asyncio.CancelledError:
pass

with redys.v2.AClient() as bus:
await bus.unsubscribe(self.hr.hid.EVENT_RESPONSE_UPDATE)

Expand Down
10 changes: 6 additions & 4 deletions htagweb/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,13 @@ async def startServer():
##################################################################################
async def stopServer(s):
##################################################################################
# clean all running process
await killall()
try:
# clean all running process
await killall()

# before stopping
s.stop()
finally:
# before stopping
s.stop()


if __name__=="__main__":
Expand Down
2 changes: 1 addition & 1 deletion htagweb/server/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ async def loop_tag_update(self, hrsocket, websocket):
break
await asyncio.sleep(0.1)
except Exception as e:
print("**loop_tag_update, broken bus, will stop the loop_tag_update !**")
print(f"**loop_tag_update, broken bus, will stop the loop_tag_update (often a cancel error)!**")
finally:
await self._bus.unsubscribe(event)

0 comments on commit 5f15a96

Please sign in to comment.