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

BlueZ: fix not disconnecting if get_services() throws during connect #968

Merged
merged 2 commits into from
Aug 30, 2022

Conversation

dlech
Copy link
Collaborator

@dlech dlech commented Aug 29, 2022

It is possible for get_services() to raise an exception, e.g. if external code cancels the task. If this happens, we need to be sure
that the device disconnects so the BlueZClient is in a consistent state (if the connect() method raises and exception, is is expected that the device will not be connected).

To fix this, we can just move the call to get_services() inside of the existing try block that will disconnect on any exception, then reraise the exception.

Fixes #951.

…rows

It is possible for get_services() to raise an exception, e.g. if
external code cancels the task. If this happens, we need to be sure
that the device disconnects so the BlueZClient is in a consistent
state (if the connect() method raises and exception, is is expected
that the device will not be connected).

To fix this, we can just move the call to get_services() inside of the
existing try block that will disconnect on any exception, then reraise
the exception.

Fixes #951.
@dlech
Copy link
Collaborator Author

dlech commented Aug 29, 2022

@bdraco can you please test?

@dlech dlech changed the title BlueZ: fix not disconnecting if get_services() throws BlueZ: fix not disconnecting if get_services() throws during connect Aug 29, 2022
Copy link
Contributor

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

I was not able to get the problem to reoccur with this change

@dlech dlech merged commit 77d74ed into develop Aug 30, 2022
@dlech dlech deleted the bluez-fix-bad-connect-state branch August 30, 2022 15:38
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.

Device remains connected if connection is successful but get_services receives TimeoutError during connect
2 participants