FcmPushClient.stop() closes the socket and awaits tasks on shutdown - #41
Open
drewbuerger wants to merge 1 commit into
Open
drewbuerger wants to merge 1 commit into
drewbuerger wants to merge 1 commit into
Conversation
stop() cancelled the listen/monitor tasks but never closed the socket or awaited them, so a _listen() task parked on reader.readexactly() hangs on the ssl read. Callers such as Home Assistant then log "Task could not be canceled and was still running after shutdown" and block ~15s per stop. - stop(): cancel tasks, close the writer so the read unblocks, then await the tasks (bounded by STOP_TIMEOUT_SEC) - stop(): return cleanly when called before start() (stopping_lock is None), which previously raised TypeError on 'async with None' - _terminate(): close the transport so a sibling reader unblocks (see sdb9696#33) Adds tests/test_stop_shutdown.py using a loopback socket pair (no FCM servers); the old stop() fails or hangs these.
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.
stop()cancels the listen/monitor tasks but never closes the socket or awaitsthem, so a
_listen()task parked onreader.readexactly()hangs on the SSLread. Downstream consumers such as Home Assistant's Ring integration then log
Task could not be canceled and was still running after shutdownand block~15s on every shutdown.
stop(): cancel the tasks, close the writer so the read unblocks, then awaitthe tasks (bounded by
STOP_TIMEOUT_SEC).stop(): return cleanly when called beforestart()(stopping_lockisNone) — previously raisedTypeErroronasync with None._terminate(): close the transport so a sibling reader unblocks onconnectivity loss (related to Internet connectivity dropout causing irrecoverable shutdown #33).
Adds
tests/test_stop_shutdown.pyusing a loopback socket pair (no FCM serversneeded). The old
stop()fails or hangs these.