Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress ValueError on EventsEndpoint at shutdown #7906

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

xoriole
Copy link
Contributor

@xoriole xoriole commented Feb 19, 2024

This ValueError is raised at the shutdown stage so suppressing the error is acceptable.
Fixes #7905

@xoriole xoriole self-assigned this Feb 19, 2024
@xoriole xoriole marked this pull request as ready for review February 19, 2024 13:11
@xoriole xoriole requested a review from a team as a code owner February 19, 2024 13:11
@xoriole xoriole requested review from drew2a and removed request for a team February 19, 2024 13:11
Copy link
Collaborator

@drew2a drew2a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppressing errors in the finally block does seem a bit extreme to me.

Since there are no return statements in the try block, I would suggest rewriting the block as follows:

        try:
            while not self._shutdown:
                await asyncio.sleep(1)
        except CancelledError:
            self._logger.warning('Event stream was canceled')
        else:
            self._logger.info('Event stream was closed due to shutdown')
        
        with suppress(ValueError):
            self.events_responses.remove(response)

(NIT)

@xoriole xoriole merged commit 9006867 into Tribler:main Feb 20, 2024
20 checks passed
@xoriole xoriole added this to the 7.14.0 milestone Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ValueError: list.remove(x): x not in list
2 participants