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

Natively support with context managers. #114

Open
miccoli opened this issue Jan 21, 2023 · 1 comment · May be fixed by #115
Open

Natively support with context managers. #114

miccoli opened this issue Jan 21, 2023 · 1 comment · May be fixed by #115
Labels
enhancement New feature or request

Comments

@miccoli
Copy link

miccoli commented Jan 21, 2023

In all examples involving “servers” there is a try ... finally block:

try:
    # some code
finally:
    # Unregister the DBus service and objects.
    SESSION_BUS.disconnect()

I would suggest to natively support the PEP 343 with statement, in order to allow refactoring the above code as

with SESSION_BUS:
    # some code

The implementation using with-statement context managers should be straightforward.

@poncovka poncovka linked a pull request Feb 4, 2023 that will close this issue
@poncovka
Copy link
Contributor

poncovka commented Feb 4, 2023

That makes sense. Thanks for the suggestion! The implementation is available at #115.

@poncovka poncovka added the enhancement New feature or request label Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

2 participants