webrtcd: stop cereal proxy runner when data channel is closed (#30601)

Stop the proxy when channel reaches invalid state
This commit is contained in:
Kacper Rączy 2023-12-04 19:14:11 -08:00 committed by GitHub
parent 33ee7530b3
commit 6a354ddab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -15,6 +15,7 @@ warnings.filterwarnings("ignore", category=DeprecationWarning)
import aiortc
from aiortc.mediastreams import VideoStreamTrack, AudioStreamTrack
from aiortc.contrib.media import MediaBlackhole
from aiortc.exceptions import InvalidStateError
from aiohttp import web
import capnp
from teleoprtc import WebRTCAnswerBuilder
@ -97,6 +98,9 @@ class CerealProxyRunner:
while True:
try:
self.proxy.update()
except InvalidStateError:
self.logger.warning("Cereal outgoing proxy invalid state (connection closed)")
break
except Exception as ex:
self.logger.error("Cereal outgoing proxy failure: %s", ex)
await asyncio.sleep(0.01)