9 |
9 |
10 import json |
10 import json |
11 import contextlib |
11 import contextlib |
12 |
12 |
13 from PyQt5.QtCore import ( |
13 from PyQt5.QtCore import ( |
14 pyqtSlot, QProcess, QProcessEnvironment, QCoreApplication |
14 pyqtSlot, QProcess, QProcessEnvironment, QCoreApplication, QEventLoop, |
|
15 QTimer |
15 ) |
16 ) |
16 from PyQt5.QtNetwork import QTcpServer, QHostAddress |
17 from PyQt5.QtNetwork import QTcpServer, QHostAddress |
17 |
18 |
18 from E5Gui import E5MessageBox |
19 from E5Gui import E5MessageBox |
19 |
20 |
241 if not proc.waitForStarted(10000): |
242 if not proc.waitForStarted(10000): |
242 proc = None |
243 proc = None |
243 |
244 |
244 if idString: |
245 if idString: |
245 self.__clientProcesses[idString] = proc |
246 self.__clientProcesses[idString] = proc |
246 # wait until the client has connected (= slow start) |
247 if proc: |
247 while idString not in self.__connections: |
248 timer = QTimer() |
248 QCoreApplication.processEvents() |
249 timer.setSingleShot(True) |
|
250 timer.start(30000) # 30s timeout |
|
251 while (idString not in self.connectionNames() |
|
252 and timer.isActive() |
|
253 ): |
|
254 # Give the event loop the chance to process the new |
|
255 # connection of the client (= slow start). |
|
256 QCoreApplication.processEvents( |
|
257 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) |
249 else: |
258 else: |
250 self.__clientProcess = proc |
259 self.__clientProcess = proc |
251 |
260 |
252 return proc is not None |
261 return proc is not None |
253 |
262 |