@@ -166,23 +166,29 @@ def __check_session_header(self):
166166
167167 def __handle_readiness (self ):
168168 """ Handle readiness probe. """
169- with DBSession (self .server .config_session ) as cfg_sess :
170- try :
171- cfg_sess .query (ORMConfiguration ).count ()
172-
173- self .send_response (200 )
174- self .end_headers ()
175- self .wfile .write (b'CODECHECKER_SERVER_IS_READY' )
176- except Exception :
177- self .send_response (500 )
178- self .end_headers ()
179- self .wfile .write (b'CODECHECKER_SERVER_IS_NOT_READY' )
169+ try :
170+ with DBSession (self .server .config_session ) as cfg_sess :
171+ try :
172+ cfg_sess .query (ORMConfiguration ).count ()
173+
174+ self .send_response (200 )
175+ self .end_headers ()
176+ self .wfile .write (b'CODECHECKER_SERVER_IS_READY' )
177+ except Exception :
178+ self .send_response (500 )
179+ self .end_headers ()
180+ self .wfile .write (b'CODECHECKER_SERVER_IS_NOT_READY' )
181+ except BrokenPipeError :
182+ pass
180183
181184 def __handle_liveness (self ):
182185 """ Handle liveness probe. """
183- self .send_response (200 )
184- self .end_headers ()
185- self .wfile .write (b'CODECHECKER_SERVER_IS_LIVE' )
186+ try :
187+ self .send_response (200 )
188+ self .end_headers ()
189+ self .wfile .write (b'CODECHECKER_SERVER_IS_LIVE' )
190+ except BrokenPipeError :
191+ pass
186192
187193 def end_headers (self ):
188194 """
@@ -518,10 +524,11 @@ def do_POST(self):
518524 return
519525
520526 except BrokenPipeError as ex :
527+ # This is considered normal. The client can close the TCP
528+ # connection for various reasons and the server cannot
529+ # write to a closed socket.
521530 LOG .warning ("%s failed with BrokenPipeError: %s" ,
522531 api_info , str (ex ))
523- import traceback
524- traceback .print_exc ()
525532 except Exception as ex :
526533 if isinstance (ex , ProductNotFoundError ):
527534 LOG .debug ("%s failed with Exception: %s" , api_info , str (ex ))
0 commit comments