React to the debugpyAttach event and try and start a new session; this gets tripped up by the _vimspector.Variables (etc) buffers already existing. Probably need to add the sesssion ID to the buffer name
This commit is contained in:
parent
099431ba55
commit
0cdab6be4e
7 changed files with 117 additions and 10 deletions
|
|
@ -27,12 +27,10 @@ endif
|
|||
function! vimspector#internal#state#Reset() abort
|
||||
try
|
||||
py3 import vim
|
||||
py3 _vimspector_session_manager = __import__(
|
||||
py3 _vimspector_session = __import__(
|
||||
\ "vimspector",
|
||||
\ fromlist=[ "session_manager" ] ).session_manager.SessionManager()
|
||||
|
||||
py3 _vimspector_session = _vimspector_session_manager =
|
||||
\ _vimspector_session_manager.NewSession( vim.eval( 's:prefix' ) )
|
||||
\ fromlist=[ "session_manager" ] ).session_manager.Get().NewSession(
|
||||
\ vim.eval( 's:prefix' ) )
|
||||
catch /.*/
|
||||
echohl WarningMsg
|
||||
echom 'Exception while loading vimspector:' v:exception
|
||||
|
|
|
|||
46
python3/vimspector/custom/python.py
Normal file
46
python3/vimspector/custom/python.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# vimspector - A multi-language debugging system for Vim
|
||||
# Copyright 2021 Ben Jackson
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from vimspector.debug_session import DebugSession
|
||||
from vimspector import session_manager
|
||||
|
||||
from typing import Sequence
|
||||
|
||||
|
||||
class Debugpy( object ):
|
||||
parent: DebugSession
|
||||
sessions: Sequence[ DebugSession ]
|
||||
|
||||
def __init__( self, debug_session: DebugSession ):
|
||||
self.parent = debug_session
|
||||
|
||||
|
||||
def OnEvent_debugpyAttach( self, message ):
|
||||
# Debugpy sends us the contents of a launch request that we should use. We
|
||||
# probaly just jave to guess the rest
|
||||
launch_argyments = message[ 'body' ]
|
||||
session = session_manager.Get().NewSession( self.parent._api_prefix )
|
||||
|
||||
# Inject the launch config (HACK!). This will actually mean that the
|
||||
# configuration passed below is ignored.
|
||||
session._launch_config = launch_argyments
|
||||
|
||||
# FIXME: We probably do need to add a StartWithLauncArguments and somehow
|
||||
# tell the new session that it shoud not support "Restart" requests ?
|
||||
#
|
||||
# In fact, what even would Reset do... ?
|
||||
session._StartWithConfiguration( self.parent._configuration,
|
||||
self.parent._adapter )
|
||||
|
||||
|
|
@ -1190,9 +1190,10 @@ class DebugSession( object ):
|
|||
self._on_init_complete_handlers = []
|
||||
|
||||
self._logger.debug( "LAUNCH!" )
|
||||
self._launch_config = {}
|
||||
self._launch_config.update( self._adapter.get( 'configuration', {} ) )
|
||||
self._launch_config.update( self._configuration[ 'configuration' ] )
|
||||
if self._launch_config is None:
|
||||
self._launch_config = {}
|
||||
self._launch_config.update( self._adapter.get( 'configuration', {} ) )
|
||||
self._launch_config.update( self._configuration[ 'configuration' ] )
|
||||
|
||||
request = self._configuration.get(
|
||||
'remote-request',
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ GADGETS = {
|
|||
# doesn't support the custom messages)
|
||||
# https://github.com/puremourning/vimspector/issues/141
|
||||
"subProcess": False,
|
||||
}
|
||||
},
|
||||
'custom_handler': 'vimspector.custom.python.Debugpy'
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
|
||||
from vimspector.debug_session import DebugSession
|
||||
|
||||
# Singleton
|
||||
_session_manager = None
|
||||
|
||||
|
||||
class SessionManager:
|
||||
next_session_id = 0
|
||||
|
|
@ -41,6 +44,13 @@ class SessionManager:
|
|||
def GetSession( self, session_id ):
|
||||
return self.sessions.get( session_id )
|
||||
|
||||
|
||||
def CurrentSession( self ):
|
||||
return self.GetSession( self.current_session )
|
||||
|
||||
|
||||
def Get():
|
||||
global _session_manager
|
||||
if _session_manager is None:
|
||||
_session_manager = SessionManager()
|
||||
|
||||
return _session_manager
|
||||
|
|
|
|||
24
support/test/python/multiprocessing/.vimspector.json
Normal file
24
support/test/python/multiprocessing/.vimspector.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json",
|
||||
"configurations": {
|
||||
"run": {
|
||||
"adapter": "debugpy",
|
||||
"configuration": {
|
||||
"request": "launch",
|
||||
"type": "python",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "${file}",
|
||||
"stopOnEntry": false,
|
||||
"console": "integratedTerminal",
|
||||
"subProcess": true
|
||||
},
|
||||
"breakpoints": {
|
||||
"exception": {
|
||||
"raised": "N",
|
||||
"uncaught": "Y",
|
||||
"userUnhandled": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
support/test/python/multiprocessing/multiprocessing_test.py
Normal file
27
support/test/python/multiprocessing/multiprocessing_test.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import time
|
||||
import multiprocessing as mp
|
||||
|
||||
|
||||
def First():
|
||||
for _ in range( 100 ):
|
||||
print( "in first" )
|
||||
time.sleep( 0.1 )
|
||||
|
||||
|
||||
def Second():
|
||||
for _ in range( 100 ):
|
||||
print( "in second" )
|
||||
time.sleep( 0.1 )
|
||||
|
||||
|
||||
print( "main" )
|
||||
p1 = mp.Process( target=First )
|
||||
p2 = mp.Process( target=Second )
|
||||
|
||||
p1.start()
|
||||
p2.start()
|
||||
|
||||
p1.join()
|
||||
p2.join()
|
||||
|
||||
print( "Done" )
|
||||
Loading…
Add table
Add a link
Reference in a new issue