From: Michael Albinus <michael.albinus@gmx.de>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: 33018@debbugs.gnu.org
Subject: bug#33018: 26.1.50; thread starvation with async processes and accept-process-output
Date: Mon, 15 Oct 2018 10:02:53 +0200 [thread overview]
Message-ID: <87sh177i36.fsf@gmx.de> (raw)
In-Reply-To: <878t30h823.fsf@tcd.ie> (Basil L. Contovounesios's message of "Sun, 14 Oct 2018 16:17:08 +0100")
[-- Attachment #1: Type: text/plain, Size: 862 bytes --]
"Basil L. Contovounesios" <contovob@tcd.ie> writes:
Hi Basil,
>> If you want a process to communicate in a given thread, you must call
>> `set-process-thread'. See the elisp manual.
>
> Thanks, this is the first thing I tried when earlier experiments started
> to hang. I tried both the following redundant but explicit call:
Well, I've played with your example. As Eli said, `set-process-thread'
is not needed here.
With your original example, I could reproduce the problem, However, if I
call
emacs -l test.el -f test-threads
the problem does NOT happen. My .emacs is quite long, so I didn't bisect
in order to find out what makes the difference.
I have changed your example a little bit wrt `thread-join', see
appended. This version runs w/o any problem even if emacs is called with
-Q. Maybe this helps you to debug further.
Best regards, Michael.
[-- Attachment #2: Type: text/plain, Size: 1919 bytes --]
;;; test.el --- test -*- lexical-binding: t -*-
;;; Code:
(defun test-debug (proc &rest args)
"Print `current-thread' and ARGS in timestamped `message'."
(message
"[%s] %s"
(format-time-string "%T:%3N")
(mapconcat
#'prin1-to-string `(,(current-thread) ,(process-thread proc) ,@args) " ")))
(defun test-sentinel (proc msg)
"Kill buffer of PROC when it exits."
(test-debug proc 'sentinel (process-status proc) (substring msg 0 -1))
(and (not (eq (process-status proc) 'run))
(buffer-live-p (process-buffer proc))
(kill-buffer (process-buffer proc))))
(defun test-slave ()
"Create an asynchronous process and wait for it to exit."
(let ((proc (make-process
:name "test"
:buffer (generate-new-buffer " *test*")
:command '("wget" "-qO-" "https://en.wikipedia.org/wiki/Emacs")
:connection-type 'pipe
:sentinel #'test-sentinel)))
(while (eq (process-status proc) 'run)
(test-debug proc 'accept-output (accept-process-output proc 5)))
(test-debug proc 'exit (process-status proc) (process-exit-status proc))))
(defun test-master (async)
"Successively run `test-slave'.
With non-nil ASYNC, use a new thread for each invocation."
(if async
(progn
(dotimes (i 5) (make-thread #'test-slave (format "test-%d" i)))
(while (cdr (all-threads) (thread-join (cadr (all-threads))))))
(dotimes (i 5)
(test-slave))))
(defun test-job (async)
"Successively run `test-slave'.
Like `test-master', but avoid blocking interactive sessions by
running `test-master' in its own thread."
(if noninteractive
(test-master async)
(make-thread (apply-partially #'test-master async) "test-master")))
(defun test-threads ()
"Run `test-master' with threads."
(test-job t))
(defun test-no-threads ()
"Run `test-master' without threads."
(test-job nil))
;;; test.el ends here
next prev parent reply other threads:[~2018-10-15 8:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 14:57 bug#33018: 26.1.50; thread starvation with async processes and accept-process-output Basil L. Contovounesios
2018-10-12 8:07 ` Eli Zaretskii
2018-10-14 15:00 ` Basil L. Contovounesios
2018-10-14 15:17 ` Eli Zaretskii
2018-10-14 15:36 ` Basil L. Contovounesios
2018-10-12 12:02 ` Michael Albinus
2018-10-12 12:43 ` Eli Zaretskii
2018-10-12 12:49 ` Michael Albinus
2018-10-14 15:17 ` Basil L. Contovounesios
2018-10-15 8:02 ` Michael Albinus [this message]
2018-10-16 1:15 ` Basil L. Contovounesios
2018-10-16 13:54 ` Michael Albinus
2018-10-16 14:55 ` Basil L. Contovounesios
2018-10-16 14:58 ` Eli Zaretskii
2018-10-17 17:37 ` Basil L. Contovounesios
2018-10-17 17:56 ` Eli Zaretskii
2018-10-17 18:05 ` Basil L. Contovounesios
2018-10-17 18:20 ` Eli Zaretskii
2018-10-17 18:25 ` Eli Zaretskii
2018-10-17 20:46 ` Basil L. Contovounesios
2018-10-20 8:34 ` Eli Zaretskii
2018-10-17 20:02 ` Basil L. Contovounesios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sh177i36.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=33018@debbugs.gnu.org \
--cc=contovob@tcd.ie \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.