执行python的dap-debug,在compile时卡住

python

#1

最近在windows下lsp-mode编写python用得很愉快,各项补全,doc功能都没有任何delay的问题。

唯独dap-debug一直没有成功,我的dap-mode设定如下:

(use-package dap-mode
   after lsp-mode
  :commands dap-debug
  :init (dap-mode 1)
        (dap-ui-mode 1)
  :config  (require 'dap-python))

执行dap-debug后在compilation会显示

-*- mode: compilation; default-directory: "d:/gui/" -*-
Compilation started at Sun Jul 28 22:15:06

c:/Python37/python.exe -m ptvsd --wait --host localhost --port 32000 d:/gui/Market.py 

接著就一直停住,我试过在不中断compile时直接再执行dap-debug,结果是一样的。

目前所用的ptvsd版本是最新的4.3.0,也试过其他版本的ptvsd,也是一样结果。 并且显示如下的message:

Failed to connect to localhost:32000 with error message make client process failed: Connection refused, :name, *connection-test*, :buffer, nil, :host, localhost, :service, 32000, :nowait, nil, :tls-parameters, nil

请教各位大神,此问题如何解?


#2

遇到了同样的问题。


#3

Linux下使用没有遇到问题,是否跟防火墙之类的有关?


#4

试过关闭防火墙没用,看似是dap-server没有启动,所以一开始就连线不到


#5

看看dap和ptvsd的log


#6

试过在环境变数中加了 PTVSD_LOG_DIR, 但没有任何log档案产生。

试了中断compilation,显示下面的讯息,看起来是IPC的问题,不知如何处理

-*- mode: compilation; default-directory: "d:/Stock/gui/" -*-
Compilation started at Wed Sep 11 01:21:35

c:/Python37/python.exe -m ptvsd --wait --host localhost --port 32000 d:/Stock/gui/TwseBase.py 
Exception in thread ptvsd.Server:
Traceback (most recent call last):
  File "c:\Python37\lib\site-packages\ptvsd\ipcjson.py", line 315, in process_one_message
    msg = self.__message.pop(0)
IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Python37\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "c:\Python37\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "c:\Python37\lib\site-packages\ptvsd\wrapper.py", line 906, in process_messages
    self.process_messages()
  File "c:\Python37\lib\site-packages\ptvsd\ipcjson.py", line 305, in process_messages
    self.process_one_message()
  File "c:\Python37\lib\site-packages\ptvsd\ipcjson.py", line 318, in process_one_message
    self._wait_for_message()
  File "c:\Python37\lib\site-packages\ptvsd\ipcjson.py", line 179, in _wait_for_message
    "Malformed header, expected 'name: value'\n" + line)
ptvsd.ipcjson.InvalidHeaderError: Malformed header, expected 'name: value'


Traceback (most recent call last):
  File "c:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\Python37\lib\site-packages\ptvsd\__main__.py", line 269, in <module>
    main()
  File "c:\Python37\lib\site-packages\ptvsd\__main__.py", line 265, in main
    wait=args.wait)
  File "c:\Python37\lib\site-packages\ptvsd\__main__.py", line 258, in handle_args
    debug_main(addr, name, kind, *extra, **kwargs)
  File "c:\Python37\lib\site-packages\ptvsd\_local.py", line 45, in debug_main
    run_file(address, name, *extra, **kwargs)
  File "c:\Python37\lib\site-packages\ptvsd\_local.py", line 79, in run_file
    run(argv, addr, **kwargs)
  File "c:\Python37\lib\site-packages\ptvsd\_local.py", line 140, in _run
    _pydevd.main()
  File "c:\Python37\lib\site-packages\ptvsd\_vendored\pydevd\pydevd.py", line 1934, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "c:\Python37\lib\site-packages\ptvsd\_vendored\pydevd\pydevd.py", line 1239, in run
    time.sleep(0.1)  # busy wait until we receive run command
KeyboardInterrupt

Compilation unknown signal at Wed Sep 11 01:22:22