unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 33018@debbugs.gnu.org
Subject: bug#33018: 26.1.50; thread starvation with async processes and accept-process-output
Date: Sun, 14 Oct 2018 16:17:08 +0100	[thread overview]
Message-ID: <878t30h823.fsf@tcd.ie> (raw)
In-Reply-To: <875zy7cqzd.fsf@gmx.de> (Michael Albinus's message of "Fri, 12 Oct 2018 14:02:46 +0200")

[-- Attachment #1: Type: text/plain, Size: 775 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:

> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>> I attach a sample program test.el whose central function, test-slave,
>> invokes wget asynchronously before waiting for the process to exit.
>>
>> The issue I'm facing is that running test-slave twice in succession,
>> each time in a new thread, causes accept-process-output to hang with no
>> output (unless a timeout argument is given, in which case the function
>> returns nil) the second time around.
>
> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test.diff --]
[-- Type: text/x-diff, Size: 616 bytes --]

diff -u --label /tmp/test.el --label \#\<buffer\ /tmp/test.el\> /tmp/test.el /tmp/buffer-content-hY0EDf
--- /tmp/test.el
+++ #<buffer /tmp/test.el>
@@ -24,6 +24,7 @@
                :command '("wget" "-qO-" "https://en.wikipedia.org/wiki/Emacs")
                :connection-type 'pipe
                :sentinel #'test-sentinel)))
+    (set-process-thread proc (current-thread))
     (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))))

Diff finished.  Sun Oct 14 16:04:48 2018

[-- Attachment #3: Type: text/plain, Size: 295 bytes --]


as well as replacing (current-thread) with nil, to unlock the process.

Adding test-debug calls before and after accept-process-output revealed
nothing out of the ordinary, and explicitly un/locking the process
didn't fix the hang.  Should I be calling set-process-thread elsewhere?

-- 
Basil

  parent reply	other threads:[~2018-10-14 15:17 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 [this message]
2018-10-15  8:02     ` Michael Albinus
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878t30h823.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=33018@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).