[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Async process sentinel running exclusively in main thread?
From: |
Emanuel Berg |
Subject: |
Re: Async process sentinel running exclusively in main thread? |
Date: |
Tue, 21 Jun 2022 08:29:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Félix Baylac Jacqué wrote:
> (defun h--tests-init-fake-git-repo (dir)
> "Create a dummy git repo at DIR.
>
> If DIR doesn't exist, we create it first."
> (let* ((d (file-name-as-directory dir))
> (exit-code 0)
Not used ...
> (git-process
> (progn
> (make-directory d t)
> (h--call-git-in-dir d
> (lambda (ec) (setq exit-code ec))
> "init"))))
> (progn
Not needed.
> (unless (file-directory-p d) (make-directory d t))
> ;; ERT does not handle async processes gracefully for the time
> ;; being. Blocking and waiting for the git process to exit
> ;; before moving on.
> (while (accept-process-output git-process)))))
In the docstring it doesn't say the BODY of `while' is
optional, but I just tried and it works.
Here, try it yourself, it'll hang your computer:
(while t)
Ha. Just kidding ...
> (defun test-make-process ()
> (let* ((run-async-process
> (lambda ()
> (progn
Not needed.
> (message (format "run-async-process thread: %s"
> (prin1-to-string(current-thread))))
You don't need `message' and then `format',
(message "%s number %d" "Elisp programmer" 1) ; "Elisp programmer number 1"
> (make-process
> :name "dummy-async-subprocess"
> :buffer "sleep-buf"
> :command '("sleep" "5"))))))
> (progn
Not needed.
> (setq process (make-thread run-async-process))
Free variable, first use `defvar' if it should be global.
--
underground experts united
https://dataswamp.org/~incal