From d9d73d80a81a9cc6b382e0bec022c267342c6d83 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 6 Nov 2025 20:33:37 +0100 Subject: [PATCH] [python] PY-85433: Survive `IOException` thrown by `read`. While closing remote stream should lead to `EOF` (`-1`), `read` might still throw `IOException`. This is documented by the `read` contract, and we face it when underlying stream gets closed i.e: one thread was blocked by `read` and another one called `close`. GitOrigin-RevId: 6cb291a720fbaab85909dee5291f6f68d820ece7 --- .../execService/impl/processAwaiter.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processAwaiter.kt b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processAwaiter.kt index 0a8c94d68ee8..286249017c1d 100644 --- a/python/python-exec-service/src/com/intellij/python/community/execService/impl/processAwaiter.kt +++ b/python/python-exec-service/src/com/intellij/python/community/execService/impl/processAwaiter.kt @@ -1,6 +1,7 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.python.community.execService.impl +import com.intellij.openapi.diagnostic.fileLogger import com.intellij.platform.eel.provider.utils.EelProcessExecutionResult import com.intellij.python.community.execService.ProcessEvent import com.intellij.python.community.execService.ProcessEvent.OutputType @@ -12,11 +13,14 @@ import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.withContext +import org.jetbrains.annotations.ApiStatus +import java.io.IOException /** * Awaits of process result and reports its stdout/stderr as a progress. */ -internal suspend fun Process.awaitWithReporting(progressListener: FlowCollector?): EelProcessExecutionResult = +@ApiStatus.Internal +suspend fun Process.awaitWithReporting(progressListener: FlowCollector?): EelProcessExecutionResult = coroutineScope { val stdout = async { report(STDOUT, progressListener) } val stderr = async { report(STDERR, progressListener) } @@ -36,7 +40,13 @@ private suspend fun Process.report(outputType: OutputType, to: FlowCollector