[python] PY-83881 use project service to cancel project configuration on closing the project.

(cherry picked from commit fb57a6ca4cdd77d2a725a083e91659829924748a)

IJ-CR-181097

GitOrigin-RevId: 845c1c89b2ff86eace4d1e9b2b9f2e283d4b8995
This commit is contained in:
Vladimir.Koshelev
2025-11-03 21:42:44 +00:00
committed by intellij-monorepo-bot
parent e431ddbba0
commit 1926f35d74
@@ -33,7 +33,6 @@ import com.intellij.python.sdkConfigurator.common.enableSDKAutoConfigurator
import com.intellij.util.PlatformUtils
import com.jetbrains.python.PyBundle
import com.jetbrains.python.getOrLogException
import com.jetbrains.python.packaging.utils.PyPackageCoroutine
import com.jetbrains.python.sdk.*
import com.jetbrains.python.sdk.conda.PyCondaSdkCustomizer
import com.jetbrains.python.sdk.configuration.CreateSdkInfo
@@ -80,7 +79,7 @@ class PythonSdkConfigurator : DirectoryProjectConfigurator {
StartupManager.getInstance(project).runWhenProjectIsInitialized(object : Runnable, DumbAware {
override fun run() {
if (module.isDisposed) return
service<MyCoroutineScopeProvider>().coroutineScope.launch {
project.service<MyCoroutineScopeProvider>().coroutineScope.launch {
val sdkInfos = findSuitableCreateSdkInfos(module)
withBackgroundProgress(project, PySdkBundle.message("python.configuring.interpreter.progress"), true) {
val lifetime = suppressTipAndInspectionsFor(module, "all suitable extensions")
@@ -271,5 +270,5 @@ class PythonSdkConfigurator : DirectoryProjectConfigurator {
}
}
@Service
private class MyCoroutineScopeProvider(val coroutineScope: CoroutineScope)
@Service(Service.Level.PROJECT)
private class MyCoroutineScopeProvider(private val project: Project, val coroutineScope: CoroutineScope)