@@ -81,18 +81,19 @@ def __init__(self):
8181
8282 def start_server_client (self ):
8383 logging .debug ("Starting server client..." )
84- self ._server_client = Client (("localhost" , 6999 ), authkey = b'studio-debugger' )
84+ self ._server_client = Client (("localhost" , 6999 ), authkey = self . pref . get ( "IPC::authkey" ) )
8585 self ._server_client .send ("SERVER" )
8686 self ._server_client .send (Message ("HOOK" , payload = {"set" : "styles" , "value" : self .style }))
8787
8888 def stream_client (self ):
8989 logging .debug ("Starting stream client..." )
90- self ._stream_client = Client (("localhost" , 6999 ), authkey = b'studio-debugger' )
90+ self ._stream_client = Client (("localhost" , 6999 ), authkey = self . pref . get ( "IPC::authkey" ) )
9191 self ._stream_client .send ("STREAM" )
9292 while True :
9393 try :
9494 msg = self ._stream_client .recv ()
95- except ConnectionAbortedError :
95+ except (ConnectionAbortedError , ConnectionResetError ):
96+ self .exit ()
9697 break
9798 if msg == "TERMINATE" :
9899 self .exit ()
@@ -114,9 +115,17 @@ def transmit(self, msg, response=False):
114115 return
115116 if isinstance (msg , Message ):
116117 msg .payload = marshal (msg .payload )
117- self ._server_client .send (msg )
118+ try :
119+ self ._server_client .send (msg )
120+ except (ConnectionResetError , ConnectionAbortedError ):
121+ self ._server_client = None
122+ return
118123 if response :
119- result = self ._server_client .recv ()
124+ try :
125+ result = self ._server_client .recv ()
126+ except (ConnectionResetError , ConnectionAbortedError , EOFError ):
127+ self ._server_client = None
128+ return
120129 logger .debug ("Received response: %s" , result )
121130 if isinstance (result , Exception ):
122131 raise result
0 commit comments