| 392 | |
| 393 | |
| 394 | class MyRPCServer(rpc.RPCServer): |
| 395 | |
| 396 | def handle_error(self, request, client_address): |
| 397 | """Override RPCServer method for IDLE |
| 398 | |
| 399 | Interrupt the MainThread and exit server if link is dropped. |
| 400 | |
| 401 | """ |
| 402 | global quitting |
| 403 | try: |
| 404 | raise |
| 405 | except SystemExit: |
| 406 | raise |
| 407 | except EOFError: |
| 408 | global exit_now |
| 409 | exit_now = True |
| 410 | thread.interrupt_main() |
| 411 | except: |
| 412 | erf = sys.__stderr__ |
| 413 | print(textwrap.dedent(f""" |
| 414 | {'-'*40} |
| 415 | Unhandled exception in user code execution server!' |
| 416 | Thread: {threading.current_thread().name} |
| 417 | IDLE Client Address: {client_address} |
| 418 | Request: {request!r} |
| 419 | """), file=erf) |
| 420 | traceback.print_exc(limit=-20, file=erf) |
| 421 | print(textwrap.dedent(f""" |
| 422 | *** Unrecoverable, server exiting! |
| 423 | |
| 424 | Users should never see this message; it is likely transient. |
| 425 | If this recurs, report this with a copy of the message |
| 426 | and an explanation of how to make it repeat. |
| 427 | {'-'*40}"""), file=erf) |
| 428 | quitting = True |
| 429 | thread.interrupt_main() |
| 430 | |
| 431 | |
| 432 | # Pseudofiles for shell-remote communication (also used in pyshell) |