Skip to content

Proposal: Remove exceptions from Display.add_socket() #54

@heuer

Description

@heuer

Im my opinion it would nice if the method does not raise any exception but return None in case of an error.
This would largely correspond to the C implementation, which returns -1 in case of error and 0 in case of success.
In my suggestion -1 would be None and 0 would be the name of the socket.
In my opinion, the compositor should be responsible for responding to an error, not pywayland.

See also https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/486 why it might make sense to try multiple socket names.

If the method does not raise any errors, the following implementation would be possible without catching a generic Exception:

for i in range(1, 33):
    if display.add_socket(f'wayland-{i}'):
        break

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions