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

Separate server start / stop logic #559

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Separate server start / stop logic #559

merged 1 commit into from
Jul 24, 2024

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jul 24, 2024

Summary

Follow-up to #558

This PR separates the server start and stop logic.

This is required because the extension could skip starting the server in the following cases:

  1. No Python interpreter is selected
  2. Python extension is unable to resolve the environment for the given Python interpreter
  3. Python version is incompatible

So, if the extension was already running and the settings were updated to hit any one of the above cases, the server would still be running (not ideal).

Test Plan

Here, the diagnostics should disappear because the server stopped first before checking for the interpreter.

For (1),

I'd need to uninstall all Python versions for me to reproduce this so I'm skipping this scenario assuming that (2) and (3) is sufficient.

For (2),

Screen.Recording.2024-07-24.at.20.40.07.mov

For (3),

Screen.Recording.2024-07-24.at.20.38.43.mov

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it much clearer. Thanks for doing the refactor.

Comment on lines 273 to 276
export async function deactivate(): Promise<void> {
if (lsClient) {
await lsClient.stop();
await stopServer(lsClient);
}
}
Copy link
Member Author

@dhruvmanila dhruvmanila Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is a bugfix because otherwise the listeners wouldn't be disposed.

dhruvmanila added a commit that referenced this pull request Jul 24, 2024
## Summary

This PR is a refactor to use `try .. finally` in the logic which starts
the server to always reset the debounce state variable
(`restartInProgress`). This is to ensure that it's always reset even in
case of a failure.

## Test Plan

Refer to the test plan in
#559.
Base automatically changed from dhruv/finally to main July 24, 2024 19:32
@dhruvmanila dhruvmanila merged commit 4f75f0f into main Jul 24, 2024
6 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/stop branch July 24, 2024 19:34
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.

2 participants