Finalizes the debug session. If the server is present, sends "disconnect" request with "terminateDebuggee" set as specified request to it; waits for it to disconnect, allowing any remaining messages from it to be handled; and closes the server channel. If the launch
(self, why, terminate_debuggee=None)
| 133 | return True |
| 134 | |
| 135 | def finalize(self, why, terminate_debuggee=None): |
| 136 | """Finalizes the debug session. |
| 137 | |
| 138 | If the server is present, sends "disconnect" request with "terminateDebuggee" |
| 139 | set as specified request to it; waits for it to disconnect, allowing any |
| 140 | remaining messages from it to be handled; and closes the server channel. |
| 141 | |
| 142 | If the launcher is present, sends "terminate" request to it, regardless of the |
| 143 | value of terminate; waits for it to disconnect, allowing any remaining messages |
| 144 | from it to be handled; and closes the launcher channel. |
| 145 | |
| 146 | If the client is present, sends "terminated" event to it. |
| 147 | |
| 148 | If terminate_debuggee=None, it is treated as True if the session has a Launcher |
| 149 | component, and False otherwise. |
| 150 | """ |
| 151 | |
| 152 | if self.is_finalizing: |
| 153 | return |
| 154 | self.is_finalizing = True |
| 155 | log.info("{0}; finalizing {1}.", why, self) |
| 156 | |
| 157 | if terminate_debuggee is None: |
| 158 | terminate_debuggee = bool(self.launcher) |
| 159 | |
| 160 | try: |
| 161 | self._finalize(why, terminate_debuggee) |
| 162 | except Exception: |
| 163 | # Finalization should never fail, and if it does, the session is in an |
| 164 | # indeterminate and likely unrecoverable state, so just fail fast. |
| 165 | log.swallow_exception("Fatal error while finalizing {0}", self) |
| 166 | os._exit(1) |
| 167 | |
| 168 | log.info("{0} finalized.", self) |
| 169 | |
| 170 | def _finalize(self, why, terminate_debuggee): |
| 171 | # If the client started a session, and then disconnected before issuing "launch" |
no test coverage detected