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

Switch from ws4py to websockets #626

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

hamistao
Copy link
Contributor

This aims to remove ws4py as a required dependency for pylxd (although keeping it as an extra dependency for tests so we can test for backwards compat), and instead use the websockets library.
This addresses the problems reported in #615 and #585

@hamistao hamistao force-pushed the update_weblocket_lib branch 10 times, most recently from 064c6f2 to 1d9eebc Compare January 14, 2025 09:56
@hamistao
Copy link
Contributor Author

hamistao commented Jan 14, 2025

@simondeziel To my surprise, the 3.8 tests ran indefinetely here. But before (potentially) wasting time looking for the cause, I am now thinking if it isn't time to drop support for Python 3.8 and include 3.13 in our tests. 3.8 reached EOL in October 7, 2024.

Feel free to review this either way and I can address either the failing tests or the version update along with your requested changes.

@hamistao hamistao force-pushed the update_weblocket_lib branch from 1d9eebc to 0183a6c Compare January 14, 2025 10:38
@hamistao hamistao marked this pull request as ready for review January 14, 2025 10:40
This keeps `ws4py` as an optional dependency for tests, since we use it to tests backwards compatibility with user provided `ws4py` client objects.

Signed-off-by: hamistao <[email protected]>
Making `payload` as part of `kwargs` is important to use payload as an additional argument in `create_client_connection`. Also I took the liberty of improving the old log message.

Signed-off-by: hamistao <[email protected]>
This creates the three clients (for stdin, stdout and stderr) using `create_client_connection`, same as in `events`. And creates a thread for each one using the module `threading`. The logic for closing the output sockets is kept similar to how it was.

Signed-off-by: hamistao <[email protected]>
Now `create_client_connection` connects to the server on client initialization so these tests are now broken.

Signed-off-by: hamistao <[email protected]>
This function is responsible for creating a `websockets.sync.ClientConnection` client object.

Signed-off-by: hamistao <[email protected]>
This handles the new default `_WebsocketClient` appropriately and accepts a custom `ClientConnection` as an argument. If provided client is a `ws4py` client instead, fallback on handling it as such for backwards compatibility.

Signed-off-by: hamistao <[email protected]>
Now the default events websocket client connects to the server on initialization, so integration tests make more sense and we shall add them to substitute the unit tests

Signed-off-by: hamistao <[email protected]>
@hamistao hamistao force-pushed the update_weblocket_lib branch from 0183a6c to 579d064 Compare January 14, 2025 14:31
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