Skip to content

Commit

Permalink
Correctly indicate when a refresh has finished (#17336)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored Sep 9, 2021
1 parent f4c8588 commit 57eaac1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
([#17285](https://github.com/Microsoft/vscode-python/issues/17285))
1. Ensure we trigger discovery for the first time as part of extension activation.
([#17303](https://github.com/Microsoft/vscode-python/issues/17303))
1. Correctly indicate when interpreter refresh has finished.
([#17335](https://github.com/Microsoft/vscode-python/issues/17335))
1. Missing location info for `async def` functions.
([#17309](https://github.com/Microsoft/vscode-python/issues/17309))
1. For CI ensure `tensorboard` is installed in python 3 environments only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,25 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection
const stopWatch = new StopWatch();
this.refreshStarted.fire();
const iterator = this.locator.iterEnvs(query);
const refreshPromiseForQuery = this.addEnvsToCacheFromIterator(iterator);
this.refreshPromises.set(query, refreshPromiseForQuery);
return refreshPromiseForQuery.then(async () => {
this.refreshPromises.delete(query);
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, stopWatch.elapsedTime, {
interpreters: this.cache.getAllEnvs().length,
});
});
const deferred = createDeferred<void>();
// Ensure we set this before we trigger the promise to correctly indicate when a refresh has started.
this.refreshPromises.set(query, deferred.promise);
const promise = this.addEnvsToCacheFromIterator(iterator);
return promise
.then(async () => {
deferred.resolve();
this.refreshPromises.delete(query);
sendTelemetryEvent(EventName.PYTHON_INTERPRETER_DISCOVERY, stopWatch.elapsedTime, {
interpreters: this.cache.getAllEnvs().length,
});
})
.catch((ex) => deferred.reject(ex));
}

private async addEnvsToCacheFromIterator(iterator: IPythonEnvsIterator) {
const seen: PythonEnvInfo[] = [];
const state = {
done: true,
done: false,
pending: 0,
};
const updatesDone = createDeferred<void>();
Expand Down

0 comments on commit 57eaac1

Please sign in to comment.