Socket Exception trying to use Debugger in PyCharm

Answered

Hey,

I am trying to develop a Plugin for PyCharm that uses the extension points of the Python Debugger. 

When I run my plugin, PyCharm opens, and when I try to use the debugger there, I get the following exception:

2024-04-24 11:03:41,145 [  32603]   WARN - #c.j.p.d.p.MultiProcessDebugger - Socket closed
java.net.SocketException: Socket closed
    at java.base/sun.nio.ch.NioSocketImpl.endAccept(NioSocketImpl.java:694)
    at java.base/sun.nio.ch.NioSocketImpl.accept(NioSocketImpl.java:767)
    at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:675)
    at java.base/java.net.ServerSocket.platformImplAccept(ServerSocket.java:641)
    at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:617)
    at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:574)
    at java.base/java.net.ServerSocket.accept(ServerSocket.java:532)
    at com.jetbrains.python.debugger.pydev.transport.ServerModeDebuggerTransport.waitForConnect(ServerModeDebuggerTransport.java:39)
    at com.jetbrains.python.debugger.pydev.RemoteDebugger.waitForConnect(RemoteDebugger.java:118)
    at com.jetbrains.python.debugger.pydev.MultiProcessDebugger$DebuggerProcessAcceptor.run(MultiProcessDebugger.java:530)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:249)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:32)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
    at java.base/java.lang.Thread.run(Thread.java:840)

Anyone has an idea, what is wrong with my setup?

I am developing in IntelliJ IDEA Build #IU-241.14494.240 and the platform version for the target PyCharm CE is 2023.3.3 currently.

Thanks for your help.

0
5 comments

Hi Julian,

Please share the code and describe exact steps to reproduce the issue.

0

Hi Karol Lewandowski !

I just used the template code from GitHub for a new Plugin and set the target platform to PC in the gradle.properties. Then, I used the runIde Gradle Task to run my plugin. After PyCharm has started, I opened a small dummy Python Project and tried to run the Python script with the Python Debugger. My IntelliJ throws the SocketException then. At least, that's the easiest way for me to reproduce the issue.

Do you need anything else?

Thanks for your help in advance!

0

Hi Julian,

It's still too general. What project did you open? What run configuration did you run? What script? Does the same issue happen for the same project and run configuration in a non-plugin-development environment?

Also, you mentioned that you are trying to implement a plugin that “uses the extension points of the Python Debugger”. Did you start implementing it, or is it just a plan, and nothing has been done yet?

0

Hey Karol Lewandowski ! Thanks for your answer! :-)

I will try to clearify things:

  • I opened a Dummy Project with a single main.py file that includes just two variables and a print statement. But I tried it also with different projects. None of them worked.
  • My run config:
    • Script path: local path to my main.py file
    • Interpreter: local virtual environment (venv) version 3.9
    • Environment variables: PYTHONBUFFERED=1
  • I tried it also with a 3.11 configuration as well with other dummy projects like the one described earlier
  • When I use the Debugger in my productive PyCharm IDE, it works very well for these projects.
  • It is actually just a plan, but I started to explore the PyCharm/Python Debugger Extension Points but that doesn't work well if I don't have access to the Python Debugger. But for reproducing the error, I tried just the Plugin Template from GitHub and just changed the Target Platform to PC. So in both scenarios I get the SocketException Error when I try to debug one of the Python Dummy Projects in the plugin IDE.
0

Okay, it looks like the issue came from an error of the Python Debugger that obviously got fixed. The SocketException was thrown because the socket was closed immidiately after starting the debugging process without any traffic between client and server. 

After the bug was fixed, everything works fine now. I didn't have to make any changes to make it work.

0

Please sign in to leave a comment.