Repository navigation
Conversation
When the Ring backend ends a WebRTC session, handle_message() receives the
session-close and calls _close() from within the reader task itself. The
unconditional 'await read_task' then raises
RuntimeError('Task cannot await on itself'), which propagates out of the
teardown path and leaves the stream registry in a state where every
subsequent live-view attempt fails until the client is fully reinitialized
(observed via Home Assistant's ring integration on 0.9.14).
Skip awaiting the reader task when _close() is executing on that very task;
cancellation/completion is already handled by the task ending itself.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AMoo-Miki
added a commit
to AMoo-Miki/python-ring-cameras
that referenced
this pull request
Oct 9, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork: - WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534). - New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged. - Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked). - Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550). Co-authored-by: Niels Haagsman <haagsman@gmail.com> Co-authored-by: Adam Reeve <adam@adamreeve.com> Co-authored-by: danielcolquitt <daniel@colquitt.xyz> Co-authored-by: Tom Roberts <tom@tomroberts.co.uk> Co-authored-by: ben79 <benjaminfearnley@gmail.com> Co-authored-by: Aaron Wolen <aaron@wolen.com> Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki
added a commit
to AMoo-Miki/python-ring-cameras
that referenced
this pull request
Oct 9, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork: - WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534). - New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged. - Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked). - Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550). Co-authored-by: Niels Haagsman <haagsman@gmail.com> Co-authored-by: Adam Reeve <adam@adamreeve.com> Co-authored-by: danielcolquitt <daniel@colquitt.xyz> Co-authored-by: Tom Roberts <tom@tomroberts.co.uk> Co-authored-by: ben79 <benjaminfearnley@gmail.com> Co-authored-by: Aaron Wolen <aaron@wolen.com> Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki
added a commit
to AMoo-Miki/python-ring-cameras
that referenced
this pull request
Oct 16, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork: - WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534). - New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged. - Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked). - Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550). Co-authored-by: Niels Haagsman <haagsman@gmail.com> Co-authored-by: Adam Reeve <adam@adamreeve.com> Co-authored-by: danielcolquitt <daniel@colquitt.xyz> Co-authored-by: Tom Roberts <tom@tomroberts.co.uk> Co-authored-by: ben79 <benjaminfearnley@gmail.com> Co-authored-by: Aaron Wolen <aaron@wolen.com> Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki
added a commit
to AMoo-Miki/python-ring-cameras
that referenced
this pull request
Oct 16, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork: - WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534). - New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged. - Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked). - Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550). Co-authored-by: Niels Haagsman <haagsman@gmail.com> Co-authored-by: Adam Reeve <adam@adamreeve.com> Co-authored-by: danielcolquitt <daniel@colquitt.xyz> Co-authored-by: Tom Roberts <tom@tomroberts.co.uk> Co-authored-by: ben79 <benjaminfearnley@gmail.com> Co-authored-by: Aaron Wolen <aaron@wolen.com> Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki
added a commit
to AMoo-Miki/python-ring-cameras
that referenced
this pull request
Oct 16, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork: - WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534). - New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged. - Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked). - Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550). Co-authored-by: Niels Haagsman <haagsman@gmail.com> Co-authored-by: Adam Reeve <adam@adamreeve.com> Co-authored-by: danielcolquitt <daniel@colquitt.xyz> Co-authored-by: Tom Roberts <tom@tomroberts.co.uk> Co-authored-by: ben79 <benjaminfearnley@gmail.com> Co-authored-by: Aaron Wolen <aaron@wolen.com> Co-authored-by: Yoan <yoan.cousin@proton.me>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the Ring backend ends a WebRTC session server-side,
handle_message()processes the session-close and ends up calling_close()from within the reader task itself._close()then hits:Since the currently-running task is
read_task, this raises:The exception propagates out of the teardown path, and the stream bookkeeping is left in a state where every subsequent live-view attempt for that camera fails until the client is fully reinitialized.
Observed continuously via Home Assistant's
ringintegration (which pins this library; reproduced on 0.9.14 with HA 2026.7.x and 2026.8.x): the first server-side session end kills all Ring live views until the integration reloads. We've been running the one-line guard below as a local patch since early July with no recurrence.Fix
Skip awaiting the reader task when
_close()is executing on that task — completion is inherent (the task is ending), and cancellation semantics for the external-caller path are unchanged.Repro sketch
RuntimeError: Task cannot await on itselfin the close path; subsequentgenerate_async_webrtc_stream()calls for the device fail until client re-init.