gui: terminate connection on tab close

+ add method to explicitly terminate connection on qsecnode
* disconnect explicitly when closing tabs

Change-Id: I00af5fb296e1499b88eafc033f62fdcc1131a145
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30677
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft 2023-03-14 09:14:34 +01:00 committed by Markus Zolliker
parent a1271b7268
commit 8c6f1a21ab
5 changed files with 15 additions and 3 deletions

View File

@ -493,6 +493,8 @@ class SecopClient(ProxyClient):
self.txq.get(False)
except Exception:
pass
if self.io:
self.io.shutdown()
if self._txthread:
self.txq.put(None) # shutdown marker
self._txthread.join()

View File

@ -107,3 +107,6 @@ class QSECNode(QObject):
def unhandledMessage(self, action, specifier, data):
self.unhandledMsg.emit('%s %s %r' % (action, specifier, data))
def terminate_connection(self):
self.conn.disconnect()

View File

@ -229,6 +229,7 @@ class MainWindow(QMainWindow):
try:
node = self.tab.widget(index).getSecNode()
# disconnect node from all events
node.terminate_connection()
self._nodes.pop(node.nodename)
self.log.debug("Closing tab with node %s" % node.nodename)
except AttributeError:
@ -247,6 +248,5 @@ class MainWindow(QMainWindow):
def _onQuit(self):
for node in self._nodes.values():
# this is only qt signals deconnecting!
# TODO: terminate node.conn explicitly?
node.disconnect()
node.terminate_connection()
self.logwin.onClose()

View File

@ -473,7 +473,7 @@ class TearOffTabWidget(QTabWidget):
return widget
def close_current(self):
self.removeTab(self.currentIndex())
self.tabCloseRequested.emit(self.currentIndex())
class DetachedWindow(QMainWindow):

View File

@ -86,6 +86,9 @@ class AsynConn:
if cls.scheme:
cls.SCHEME_MAP[cls.scheme] = cls
def shutdown(self):
"""prepare connection for disconnect, can be empty"""
def disconnect(self):
raise NotImplementedError
@ -177,6 +180,10 @@ class AsynTcp(AsynConn):
# indicate that retrying might make sense
raise CommunicationFailedError(str(e)) from None
def shutdown(self):
if self.connection:
self.connection.shutdown(socket.SHUT_RDWR)
def disconnect(self):
if self.connection:
closeSocket(self.connection)