Override TCPServer method Error message goes to __stderr__. No error message if exiting normally or socket raised EOF. Other exceptions not handled in server code will cause os._exit.
(self, request, client_address)
| 95 | return self.socket, self.server_address |
| 96 | |
| 97 | def handle_error(self, request, client_address): |
| 98 | """Override TCPServer method |
| 99 | |
| 100 | Error message goes to __stderr__. No error message if exiting |
| 101 | normally or socket raised EOF. Other exceptions not handled in |
| 102 | server code will cause os._exit. |
| 103 | |
| 104 | """ |
| 105 | try: |
| 106 | raise |
| 107 | except SystemExit: |
| 108 | raise |
| 109 | except: |
| 110 | erf = sys.__stderr__ |
| 111 | print('\n' + '-'*40, file=erf) |
| 112 | print('Unhandled server exception!', file=erf) |
| 113 | print('Thread: %s' % threading.current_thread().name, file=erf) |
| 114 | print('Client Address: ', client_address, file=erf) |
| 115 | print('Request: ', repr(request), file=erf) |
| 116 | traceback.print_exc(file=erf) |
| 117 | print('\n*** Unrecoverable, server exiting!', file=erf) |
| 118 | print('-'*40, file=erf) |
| 119 | os._exit(0) |
| 120 | |
| 121 | #----------------- end class RPCServer -------------------- |
| 122 |