Spaces:
Paused
Paused
MacBook pro
commited on
Commit
·
fbcde68
1
Parent(s):
d999035
Install httpx and capture disconnect snapshots
Browse files- requirements.txt +2 -1
- requirements_local.txt +1 -0
- webrtc_server.py +20 -1
requirements.txt
CHANGED
|
@@ -16,4 +16,5 @@ onnx==1.16.1
|
|
| 16 |
# Use GPU build of ONNX Runtime; required for CUDAExecutionProvider on A10G
|
| 17 |
onnxruntime-gpu==1.17.1
|
| 18 |
torch==2.1.2
|
| 19 |
-
facexlib==0.3.0
|
|
|
|
|
|
| 16 |
# Use GPU build of ONNX Runtime; required for CUDAExecutionProvider on A10G
|
| 17 |
onnxruntime-gpu==1.17.1
|
| 18 |
torch==2.1.2
|
| 19 |
+
facexlib==0.3.0
|
| 20 |
+
httpx==0.27.0
|
requirements_local.txt
CHANGED
|
@@ -16,3 +16,4 @@ onnx==1.16.1
|
|
| 16 |
# Use GPU build of ONNX Runtime; required for CUDAExecutionProvider on A10G
|
| 17 |
torch==2.1.2
|
| 18 |
facexlib==0.3.0
|
|
|
|
|
|
| 16 |
# Use GPU build of ONNX Runtime; required for CUDAExecutionProvider on A10G
|
| 17 |
torch==2.1.2
|
| 18 |
facexlib==0.3.0
|
| 19 |
+
httpx==0.27.0
|
webrtc_server.py
CHANGED
|
@@ -1050,7 +1050,7 @@ async def webrtc_offer(offer: Dict[str, Any], x_api_key: Optional[str] = Header(
|
|
| 1050 |
|
| 1051 |
@pc.on("connectionstatechange")
|
| 1052 |
async def on_state_change():
|
| 1053 |
-
global _peer_state # single global declaration for entire handler
|
| 1054 |
logger.info("Peer connection state: %s", pc.connectionState)
|
| 1055 |
try:
|
| 1056 |
if _peer_state is not None:
|
|
@@ -1071,6 +1071,25 @@ async def webrtc_offer(offer: Dict[str, Any], x_api_key: Optional[str] = Header(
|
|
| 1071 |
async with _peer_lock:
|
| 1072 |
if _peer_state is not None and _peer_state.pc == pc:
|
| 1073 |
logger.info("Clearing global peer state due to connection failure")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1074 |
# Clear outbound video source to prevent hanging on retry
|
| 1075 |
if _peer_state.outbound_video:
|
| 1076 |
_peer_state.outbound_video.clear_source()
|
|
|
|
| 1050 |
|
| 1051 |
@pc.on("connectionstatechange")
|
| 1052 |
async def on_state_change():
|
| 1053 |
+
global _peer_state, _last_peer_snapshot # single global declaration for entire handler
|
| 1054 |
logger.info("Peer connection state: %s", pc.connectionState)
|
| 1055 |
try:
|
| 1056 |
if _peer_state is not None:
|
|
|
|
| 1071 |
async with _peer_lock:
|
| 1072 |
if _peer_state is not None and _peer_state.pc == pc:
|
| 1073 |
logger.info("Clearing global peer state due to connection failure")
|
| 1074 |
+
try:
|
| 1075 |
+
_peer_state.last_disconnect_reason = f"pc_state:{pc.connectionState}"
|
| 1076 |
+
except Exception:
|
| 1077 |
+
pass
|
| 1078 |
+
try:
|
| 1079 |
+
_last_peer_snapshot = {
|
| 1080 |
+
"event": "connectionstatechange",
|
| 1081 |
+
"state": pc.connectionState,
|
| 1082 |
+
"ice_state": getattr(pc, 'iceConnectionState', None),
|
| 1083 |
+
"received_video": getattr(_peer_state, 'received_video', False),
|
| 1084 |
+
"received_audio": getattr(_peer_state, 'received_audio', False),
|
| 1085 |
+
"incoming_frames": getattr(_peer_state, 'incoming_frames', 0),
|
| 1086 |
+
"incoming_first_frame_ts": getattr(_peer_state, 'incoming_first_frame_ts', None),
|
| 1087 |
+
"outbound_bind_method": getattr(_peer_state, 'outbound_bind_method', None),
|
| 1088 |
+
"outbound_sender_mid": getattr(_peer_state, 'outbound_sender_mid', None),
|
| 1089 |
+
"timestamp": time.time(),
|
| 1090 |
+
}
|
| 1091 |
+
except Exception:
|
| 1092 |
+
_last_peer_snapshot = {"event": "connectionstatechange", "state": pc.connectionState}
|
| 1093 |
# Clear outbound video source to prevent hanging on retry
|
| 1094 |
if _peer_state.outbound_video:
|
| 1095 |
_peer_state.outbound_video.clear_source()
|