diff --git a/python/src/com/jetbrains/python/console/PyConsoleUtil.java b/python/src/com/jetbrains/python/console/PyConsoleUtil.java index 2d6def7ccc11..9e3e03f24401 100644 --- a/python/src/com/jetbrains/python/console/PyConsoleUtil.java +++ b/python/src/com/jetbrains/python/console/PyConsoleUtil.java @@ -25,6 +25,7 @@ import com.intellij.util.IJSwingUtilities; import com.jetbrains.python.console.actions.CommandQueueForPythonConsoleService; import com.jetbrains.python.console.pydev.ConsoleCommunication; import com.jetbrains.python.parsing.console.PythonConsoleData; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,6 +43,8 @@ public final class PyConsoleUtil { private static final String IPYTHON_PAGING_PROMPT = "---Return to continue, q to quit---"; + public static final @NonNls String ASYNCIO_REPL_ENV = "ASYNCIO_REPL"; + private static final String[] PROMPTS = new String[]{ ORDINARY_PROMPT, INDENT_PROMPT, diff --git a/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java b/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java index 24b216f0a4fd..69ad96541448 100644 --- a/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java +++ b/python/src/com/jetbrains/python/console/PydevConsoleRunnerImpl.java @@ -102,6 +102,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import static com.intellij.execution.runners.AbstractConsoleRunnerWithHistory.registerActionShortcuts; +import static com.jetbrains.python.console.PyConsoleUtil.ASYNCIO_REPL_ENV; /** * @author traff, oleg @@ -118,8 +119,6 @@ public class PydevConsoleRunnerImpl implements PydevConsoleRunner { "sys.path.extend([" + WORKING_DIR_AND_PYTHON_PATHS + "])\n"; public static final @NonNls String STARTED_BY_RUNNER = "startedByRunner"; public static final @NonNls String INLINE_OUTPUT_SUPPORTED = "INLINE_OUTPUT_SUPPORTED"; - - private static final @NonNls String ASYNCIO_REPL_ENV = "ASYNCIO_REPL"; private static final @NonNls String ASYNCIO_REPL_COMMAND = "-m asyncio"; private static final Long WAIT_BEFORE_FORCED_CLOSE_MILLIS = 2000L; diff --git a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java index fe2e609cb0f7..cdb574800894 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java @@ -74,6 +74,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.jetbrains.python.debugger.PyDebugSupportUtils.ASYNCIO_ENV; import static com.jetbrains.python.inspections.PyInterpreterInspection.InterpreterSettingsQuickFix.showPythonInterpreterSettings; @@ -98,8 +99,6 @@ public class PyDebugRunner implements ProgramRunner { @SuppressWarnings("SpellCheckingInspection") private static final @NonNls String PYTHONPATH_ENV_NAME = "PYTHONPATH"; - private static final @NonNls String ASYNCIO_ENV = "ASYNCIO_DEBUGGER_ENV"; - private static final Logger LOG = Logger.getInstance(PyDebugRunner.class); @Override @@ -140,11 +139,6 @@ public class PyDebugRunner implements ProgramRunner { } protected Promise<@NotNull XDebugSession> createSession(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment environment) { - RunProfile runProfile = environment.getRunProfile(); - if (RegistryManager.getInstance().is("python.debug.asyncio.repl") && runProfile instanceof AbstractPythonRunConfiguration) { - ((AbstractPythonRunConfiguration) runProfile).getEnvs().put(ASYNCIO_ENV, "True"); - } - return AppUIExecutor.onUiThread() .submit(FileDocumentManager.getInstance()::saveAllDocuments) .thenAsync(ignored -> { @@ -628,6 +622,10 @@ public class PyDebugRunner implements ProgramRunner { environmentController.appendTargetPathToPathsValue(PYTHONPATH_ENV_NAME, CYTHON_EXTENSIONS_DIR); } + if (RegistryManager.getInstance().is("python.debug.asyncio.repl")) { + environmentController.putFixedValue(ASYNCIO_ENV, "True"); + } + final AbstractPythonRunConfiguration runConfiguration = runProfile instanceof AbstractPythonRunConfiguration ? (AbstractPythonRunConfiguration)runProfile : null; final Module module = runConfiguration != null ? runConfiguration.getModule() : null; diff --git a/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java b/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java index 3e8d2d87bcb4..b1fa4b3e9f17 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugSupportUtils.java @@ -14,6 +14,7 @@ import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.psi.*; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,6 +24,8 @@ public final class PyDebugSupportUtils { private PyDebugSupportUtils() { } + public static final @NonNls String ASYNCIO_ENV = "ASYNCIO_DEBUGGER_ENV"; + // can expression be evaluated, or should be executed public static boolean isExpression(final Project project, final String expression) { return ReadAction.compute(() -> {