stop reader thread on unsubscribe
This commit is contained in:
parent
ffe9c90747
commit
84c5edf5a0
1 changed files with 4 additions and 1 deletions
3
app.py
3
app.py
|
@ -216,6 +216,7 @@ async def detect(websocket: WebSocket):
|
|||
try:
|
||||
msg = await websocket.receive_text()
|
||||
logging.debug(f"Received message: {msg}")
|
||||
print(f"Received message: {msg}")
|
||||
data = json.loads(msg)
|
||||
msg_type = data.get("type")
|
||||
|
||||
|
@ -288,6 +289,8 @@ async def detect(websocket: WebSocket):
|
|||
with streams_lock:
|
||||
if camera_id and camera_id in streams:
|
||||
stream = streams.pop(camera_id)
|
||||
stream['stop_event'].set()
|
||||
stream['thread'].join()
|
||||
stream['cap'].release()
|
||||
logging.info(f"Unsubscribed from camera {camera_id}")
|
||||
if camera_id in models and modelId in models[camera_id]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue