Skip to content

Natively support with context managers. #114

@miccoli

Description

@miccoli

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions