diff --git a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java index b8af92234876..4c98c773f466 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugProcess.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugProcess.java @@ -306,12 +306,18 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr if (myProcessHandler != null) { myProcessHandler.destroyProcess(); } - LOG.error(e); + if (logConnectionException(e)) { + LOG.error(e); + } } } }); } + protected boolean logConnectionException(final Exception e) { + return true; + } + @Override public void init() { getSession().rebuildViews(); diff --git a/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java b/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java index 23d4245fe81d..bed289715152 100644 --- a/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java +++ b/python/src/com/jetbrains/python/debugger/PyRemoteDebugProcess.java @@ -3,11 +3,10 @@ package com.jetbrains.python.debugger; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.ui.ExecutionConsole; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebugSession; -import com.jetbrains.python.debugger.PyDebugProcess; -import com.jetbrains.python.debugger.PyRemoteDebugProcessAware; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -19,6 +18,7 @@ import java.net.ServerSocket; public class PyRemoteDebugProcess extends PyDebugProcess { private final int myLocalPort; private final String mySettraceCall; + private boolean isStopCalled = false; public PyRemoteDebugProcess(@NotNull XDebugSession session, @NotNull final ServerSocket serverSocket, @@ -56,11 +56,22 @@ public class PyRemoteDebugProcess extends PyDebugProcess { return "Waiting for connection"; } + @Override + protected boolean logConnectionException(Exception e) { + return !(isStopCalled && e.getMessage().contains("closed")); + } + @Override protected void detachDebuggedProcess() { waitForNextConnection(); // in case of remote debug we should wait for the next connection } + @Override + public void stop() { + super.stop(); + isStopCalled = true; + } + @Override protected void beforeConnect() { printToConsole(getCurrentStateMessage() + "\n", ConsoleViewContentType.SYSTEM_OUTPUT); @@ -79,8 +90,8 @@ public class PyRemoteDebugProcess extends PyDebugProcess { } if (!isWaitingForConnection()) { setWaitingForConnection(true); - - UIUtil.invokeLaterIfNeeded(() -> waitForConnection(getCurrentStateMessage(), getConnectionTitle())); + ApplicationManager.getApplication().invokeLater(() -> waitForConnection(getCurrentStateMessage(), getConnectionTitle()), + ModalityState.defaultModalityState()); } } diff --git a/python/testData/debug/test_remote.py b/python/testData/debug/test_remote.py index 8bccbeb44c4f..d2a241213070 100644 --- a/python/testData/debug/test_remote.py +++ b/python/testData/debug/test_remote.py @@ -9,7 +9,7 @@ if __name__ == '__main__': x = 0 - from pydev import pydevd + import pydevd pydevd.settrace('localhost', port=port, stdoutToServer=True, stderrToServer=True) x = 1 diff --git a/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java b/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java index 23e9ecbcdb65..075d299abf72 100644 --- a/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java +++ b/python/testSrc/com/jetbrains/env/python/debug/PyBaseDebuggerTask.java @@ -17,6 +17,8 @@ package com.jetbrains.env.python.debug; import com.google.common.collect.Sets; import com.intellij.execution.ExecutionResult; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.project.Project; @@ -241,8 +243,8 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask { } protected void clearAllBreakpoints() { - - UIUtil.invokeAndWaitIfNeeded((Runnable)() -> XDebuggerTestUtil.removeAllBreakpoints(getProject())); + ApplicationManager.getApplication() + .invokeLater(() -> XDebuggerTestUtil.removeAllBreakpoints(getProject()), ModalityState.defaultModalityState()); } /**