diff -r a54ad653ec6c -r 84c2fd80c949 RefactoringRope/JsonServer.py --- a/RefactoringRope/JsonServer.py Sat May 08 19:31:01 2021 +0200 +++ b/RefactoringRope/JsonServer.py Sun May 09 14:30:41 2021 +0200 @@ -11,7 +11,8 @@ import contextlib from PyQt5.QtCore import ( - pyqtSlot, QProcess, QProcessEnvironment, QCoreApplication + pyqtSlot, QProcess, QProcessEnvironment, QCoreApplication, QEventLoop, + QTimer ) from PyQt5.QtNetwork import QTcpServer, QHostAddress @@ -243,9 +244,17 @@ if idString: self.__clientProcesses[idString] = proc - # wait until the client has connected (= slow start) - while idString not in self.__connections: - QCoreApplication.processEvents() + if proc: + timer = QTimer() + timer.setSingleShot(True) + timer.start(30000) # 30s timeout + while (idString not in self.connectionNames() + and timer.isActive() + ): + # Give the event loop the chance to process the new + # connection of the client (= slow start). + QCoreApplication.processEvents( + QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) else: self.__clientProcess = proc