@@ -824,14 +824,14 @@ def setup(self):
824
824
self .request .settimeout (1.0 )
825
825
826
826
def handle (self ):
827
- # try/except end current thread on ModbusServer._InternalError or socket.error
827
+ # try/except: end current thread on ModbusServer._InternalError, OSError or socket.error
828
828
# this also close the current TCP session associated with it
829
- # init and update server info structure
830
- session_data = ModbusServer .SessionData ()
831
- (session_data .client .address , session_data .client .port ) = self .request .getpeername ()
832
- # debug message
833
- logger .debug ('accept new connection from %r' , session_data .client )
834
829
try :
830
+ # init and update server info structure
831
+ session_data = ModbusServer .SessionData ()
832
+ (session_data .client .address , session_data .client .port ) = self .request .getpeername ()
833
+ # debug message
834
+ logger .debug ('accept new connection from %r' , session_data .client )
835
835
# main processing loop
836
836
while True :
837
837
# init session data for new request
@@ -846,7 +846,7 @@ def handle(self):
846
846
self .server .engine (session_data )
847
847
# send the tx pdu with the last rx mbap (only length field change)
848
848
self ._send_all (session_data .response .raw )
849
- except (ModbusServer .Error , socket .error ) as e :
849
+ except (ModbusServer .Error , OSError , socket .error ) as e :
850
850
# debug message
851
851
logger .debug ('Exception during request handling: %r' , e )
852
852
# on main loop except: exit from it and cleanly close the current socket
0 commit comments