socket.accept hangs even with runInReadActionWithWriteActionPriority
Hello,
My plugin uses a socket connection to communicate with a running nodejs server. To handle one of the failure cases where the nodejs server becomes unavailable, I'm trying something like below (intentionally letting `socket.accept()` run and see if UI thread gets blocked):
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(new Runnable() {
public void run() {
System.out.println("trying");
ServerSocket serverSocket = new ServerSocket(0);
return serverSocket.accept();
}
});
}
});
I was expecting the above code to run and not block the UI thread, but it does (typing a few characters makes the editor become unresponsive). What I'd like to achieve is to let the `socket.accept()` call forever if nothing connects to that socket, and still have the editor available. Is this possible?
Thanks in advance!
Please sign in to leave a comment.
@Maxim, so are you saying the below code should work?
This also freezes the UI thread. Am I misunderstanding something?
Please post thread dumps of the freeze
@Maxim sure!