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

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

Open
heuer opened this issue Feb 27, 2024 · 1 comment
Open

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

heuer opened this issue Feb 27, 2024 · 1 comment

Comments

@heuer
Copy link
Contributor

heuer commented Feb 27, 2024

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
@heuer
Copy link
Contributor Author

heuer commented Mar 6, 2024

Currently the above should require the following code:

for i in range(1, 33):
    try:
        display.add_socket(f'wayland-{i}')
    except (RuntimeError, Exception):
        continue  # Maybe socket in use
    break

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

No branches or pull requests

1 participant