svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
491 stars 32 forks source link

`debugpy` will not terminate politely. #8

Closed milanglacier closed 1 year ago

milanglacier commented 1 year ago

There is a docker image which can reproduce the problem:

https://hub.docker.com/repository/docker/northyear/dape-repro/general

steps to reproduce:

  1. launch that docker image docker run -it —rm dape-repro
  2. cd ~/.emacs.d
  3. emacs -nw hello.py
  4. add a break point at the second line: sum = 0
  5. C-x C-a d debugpy RET, that is, execute dape
  6. C-x C-a c, that is, execute dape-continue.
  7. C-x C-cto quit emacs.
  8. ps -a, see that debugpy process does not quit and keep consuming high CPU usage (100% in my computer)

This is the config file used for the docker image:


(require 'package)
(setq package-user-dir "~/.emacs.d/emacs-package-dir")

(setq debug-on-error t)

(setq package-list '())
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

(setq warning-minimum-level :error)

(menu-bar-mode -1)
;;(tool-bar-mode -1)
;;(scroll-bar-mode -1)
(xterm-mouse-mode 1)

(setq scroll-step 1)
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)

(add-to-list 'load-path "~/.emacs.d/emacs-package-dir/dape")

(defun plistp (object)
  "Non-nil if and only if OBJECT is a valid plist."
  (let ((len (proper-list-p object)))
    (and len (zerop (% len 2)))))

(require 'dape)

(add-to-list 'dape-configs
                 '(debugpy
                   modes (python-ts-mode python-mode)
                   command "~/.emacs.d/venv/bin/python3"
                   command-args ("-m" "debugpy.adapter")
                   :type "executable"
                   :request "launch"
                   :cwd dape-cwd-fn
                   :program dape-find-file-buffer-default))
svaante commented 1 year ago

Nice find 👍 Please test again against master.

milanglacier commented 1 year ago

The latest patch works for me!