PY-82318: Kill process that keeps python installation.

We create SDK in tests in a temporary dir and want to drop it then.

However, some background python process (I blame package manager cache) keeps this directory which prevents it from being deleted on Windows.

We now drop it.

GitOrigin-RevId: 36e2045e57e6cfae2f31465ae6d6d8e505d5edac
This commit is contained in:
Ilya.Kazakevich
2025-06-30 04:48:09 +00:00
committed by intellij-monorepo-bot
parent 90af13819d
commit d1fcfa5850
2 changed files with 5 additions and 1 deletions
@@ -34,7 +34,7 @@ internal fun deleteCheckLockingImpl(path: Path, vararg processesToKill: Regex) {
val fileName = Path.of(command).fileName.toString()
if (processesToKill.any { it.matches(fileName) }) {
val processInfo = WinProcessInfo.get(process.pid())
fileLogger().info("Killing ${process.pid()} ${processInfo}")
fileLogger().warn("Killing ${process.pid()} ${processInfo}")
killProcess(process)
}
}
@@ -18,6 +18,7 @@ import com.intellij.python.community.junit5Tests.framework.conda.CondaEnv
import com.intellij.python.community.junit5Tests.framework.conda.PyEnvTestCaseWithConda
import com.intellij.python.community.junit5Tests.framework.conda.createCondaEnv
import com.intellij.python.junit5Tests.framework.env.pySdkFixture
import com.intellij.python.junit5Tests.framework.winLockedFile.deleteCheckLocking
import com.intellij.python.terminal.PyVirtualEnvTerminalCustomizer
import com.intellij.testFramework.common.timeoutRunBlocking
import com.intellij.testFramework.junit5.fixture.moduleFixture
@@ -67,6 +68,9 @@ class PyVirtualEnvTerminalCustomizerTest {
@AfterEach
fun tearDown(): Unit = timeoutRunBlocking {
sdkToDelete?.let { sdk ->
if (SystemInfo.isWindows) {
deleteCheckLocking(Path.of(sdk.homePath!!))
}
edtWriteAction {
ProjectJdkTable.getInstance().removeJdk(sdk)
}