Make sure to close down cleanly
This involves some horrible forceful reading on exit to ensure that we get a response to the disconnect request. This ensures that any debugee is killed cleanly.
This commit is contained in:
parent
afe4c0db77
commit
eb11712cc1
2 changed files with 38 additions and 1 deletions
|
|
@ -274,9 +274,36 @@ class DebugSession( object ):
|
|||
|
||||
self._logger.info( 'Debug Adapter Started' )
|
||||
|
||||
vim.command( 'augroup vimspector_cleanup' )
|
||||
vim.command( 'autocmd!' )
|
||||
vim.command( 'autocmd VimLeavePre * py3 _vimspector_session.CloseDown()' )
|
||||
vim.command( 'augroup END' )
|
||||
|
||||
|
||||
def CloseDown( self ):
|
||||
state = { 'done': False }
|
||||
|
||||
def handler( self ):
|
||||
state[ 'done' ] = True
|
||||
|
||||
self._connection.DoRequest( handler, {
|
||||
'command': 'disconnect',
|
||||
'arguments': {
|
||||
'terminateDebugee': True
|
||||
},
|
||||
} )
|
||||
|
||||
while not state[ 'done' ]:
|
||||
vim.eval( 'vimspector#internal#job#ForceRead()' )
|
||||
|
||||
vim.eval( 'vimspector#internal#job#StopDebugSession()' )
|
||||
|
||||
def _StopDebugAdapter( self, callback = None ):
|
||||
def handler( message ):
|
||||
vim.eval( 'vimspector#internal#job#StopDebugSession()' )
|
||||
|
||||
vim.command( 'au! vimspector_cleanup' )
|
||||
|
||||
self._connection.Reset()
|
||||
self._connection = None
|
||||
self._stackTraceView.ConnectionClosed()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue