Skip to content

Harmonize context managers and close methods - #41

Merged
lumagi merged 1 commit into
mainfrom
refactor_resource_handling
Apr 26, 2026
Merged

lumagi merged 1 commit into
mainfrom
refactor_resource_handling

Conversation

@lumagi

@lumagi lumagi commented Apr 26, 2026

Copy link
Copy Markdown
Collaborator

The close methods in the wrapper Serial classes have been removed. Furthermore, Dock and Bluetooth API won't close the underlying Serial class anymore when they themselves are closed. They didn't create the resource, so it doesn't make sense for them to close it.

Furthermore, the context manager was removed from the Dock API. Since the Dock API class does not hold any resources that it itself created there is no need for the context manager.

The serial instance should always be created within a with context, the same goes for the Bluetooth API. That way, they are always closed correctly and the with context then also handles closing of the serial interface at the right time. The examples were adjusted to reflect this.

The close methods in the wrapper Serial classes have been removed.
Furthermore, Dock and Bluetooth API won't close the underlying
Serial class anymore when they themselves are closed. They didn't create
the resource, so it doesn't make sense for them to close it.

Furthermore, the context manager was removed from the Dock API. Since
the Dock API class does not hold any resources that it itself created
there is no need for the context manager.

The serial instance should always be created within a with context,
the same goes for the Bluetooth API. That way, they are always closed
correctly and the with context then also handles closing of the serial
interface at the right time. The examples were adjusted to reflect this.
@lumagi
lumagi merged commit 70e6ceb into main Apr 26, 2026
8 checks passed
@lumagi
lumagi deleted the refactor_resource_handling branch April 26, 2026 10:46
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.

1 participant