question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shorten extension activation time by not unnecessarily awaiting async tasks within ExtensionSingleActivationServices

See original GitHub issue

_Originally posted by @DonJayamanne in https://github.com/microsoft/vscode-jupyter/pull/11572#discussion_r990499647_

    this blocks the loading of the extension, can this be done in the background, 
    all of the activate methods run when extension loads and we wait for all of them to complete.
    i would suggest using the IExtensionSync.... interface

I didn’t realize that there is an IExtensionSyncActivationService which doesn’t block (await for long running tasks), and should be used whenever possible.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
amungercommented, Oct 13, 2022

Maybe a better title would be “Shorten extension activation time by not unnecessarily awaiting async tasks within ExtensionSingleActivationServices” ?

1reaction
rebornixcommented, Oct 13, 2022

This sounds backwards - by definition synchronous will block

The blocking I’m referring to is any await happen in ExtensionSingleActivationService#activate will block the whole extension to be activated. A synchronous task will do the same, but if you have an async task but you kick off in IExtensionSyncActivationService#activate, we at least make sure that it’s a fire-and-forget, instead of holding off the extension activation process.

If this code contains some async code and MUST be completed before all of the extension starts completely then use the async version of the interface. Async stuff could be like loading somethings from files or the like. If this code contains some async code and need not be completed before all of the extension starts completely then use the non-async (IExtensionSyncActivationService) version & do not await on the promises (this way the activation will not be avaiting on these promises).

What @DonJayamanne put here is very accurate and they are the rules we want to follow.

https://github.com/microsoft/vscode-jupyter/blob/main/src/kernels/jupyter/finder/universalRemoteKernelFinderController.ts#L57 is a good example, ideally the remote kernel finder is Push Model and register kernels when it finds remote uris, but currently it’s blocking the activation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async/Await - Best Practices in Asynchronous Programming
An approach I like to take is to minimize the code in my asynchronous event handler—for example, have it await an async Task...
Read more >
Long Story Short: Async/Await Best Practices in .NET - Medium
The only time we truly want to await is when we do something with the result of the async task in the continuation...
Read more >
Using Task.Run in Conjunction with Async/Await | Pluralsight
So let's explore using Task.Run in conjunction with async/await . It's not difficult to use, but as we shall see, knowing when its...
Read more >
How to safely call an async method in C# without await
If you want to get the exception "asynchronously", you could do: MyAsyncMethod(). ContinueWith(t => Console.WriteLine(t.
Read more >
Improving Your Asynchronous Code Using Tasks, Async and ...
Dave Marini delves into the history of asynchronous programming on the . ... If the modifier is not present, await cannot be called...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found