Skip to content

Commit c0134de

Browse files
committed
Be more cautious when releasing RTCRtpSender's encoder (fixes: aiortc#1124)
We used `del` to forcibly drop the reference to the encoder and allow it to be garbage collected. However it also means that the `RTCRtpSender` no longer has an `__encoder` attribute from then on. We can encounter a race condition during shutdown where we receive an RTCP packet, which causes access to the removed `__encoder` attribute. Instead, just set the `__encoder` attribute back to `None`, as when the `RTCPRtpSender` was constructed.
1 parent 40dc82a commit c0134de

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/aiortc/rtcrtpsender.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@ async def _run_rtp(self, codec: RTCRtpCodecParameters) -> None:
406406
self.__track = None
407407

408408
# release encoder
409-
if self.__encoder:
410-
del self.__encoder
409+
self.__encoder = None
411410

412411
self.__log_debug("- RTP finished")
413412
self.__rtp_exited.set()

0 commit comments

Comments
 (0)