From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: Felix Dietrich <felix.dietrich@sperrhaken.name>
Cc: help-gnu-emacs@gnu.org
Subject: Re: trapping process filter error in a thread
Date: Sat, 02 Apr 2022 20:07:31 -0400 [thread overview]
Message-ID: <8735ivkp18.fsf@gnuvola.org> (raw)
In-Reply-To: <87k0ckt6y9.fsf@sperrhaken.name> (Felix Dietrich's message of "Thu, 24 Mar 2022 03:33:50 +0100")
[-- Attachment #1.1: Type: text/plain, Size: 1369 bytes --]
() Felix Dietrich <felix.dietrich@sperrhaken.name>
() Thu, 24 Mar 2022 03:33:50 +0100
> would like to use Emacs' threads and ‘url-http’ funcs.
You are much braver than I ;). I am not sure if the url
library is robust enough for that task, but you can certainly
try and play around with it.
'Tis a fine line between brave and foolish, i'm told. :-D
> (a) Can anyone else reproduce this on their Emacs?
Yes (also Debianʼs 27.1), but it does not appear to have
anything to do with threads: it happens just as well when you
call ‘func’ directly.
I think this tells us that error handing wrt threads are as if
they were invoked as a (top-level) command.
[analysis: chain of failures] I have not found a good way to
handle these errors with the url library.
Thanks for digging into the details. After some poking around,
i realize that the url*.el facility has quite a lot of baggage
to deal w/, as well. It's amazing how much cruft RFCs output!
> (c) Is there a recommended way to trap process filter
> errors for a noninteractive (perhaps batch) session?
Fix the process filter ;).
Haha!
I found the variable ‘command-error-function’ in the Emacs
Lisp manual [...].
Good eye! I have managed to adapt your code fragment to produce
a bad.el (attached here):
[-- Attachment #1.2: bad.el --]
[-- Type: application/emacs-lisp, Size: 878 bytes --]
[-- Attachment #1.3: Type: text/plain, Size: 52 bytes --]
that is able to trap the error (see bad.out, here):
[-- Attachment #1.4: bad.out --]
[-- Type: application/octet-stream, Size: 511 bytes --]
-*- mode: compilation; default-directory: "/tmp/" -*-
Compilation started at Sat Apr 2 19:42:08
for url in https://www.gnu.org/ https://www.gnu.org/WRONG http://www.oecd.org/pisa/test/ ; do printf '\nurl: %s\n' $url ; emacs -batch -Q -l bad.el $url ; done
url: https://www.gnu.org/
"ok"
url: https://www.gnu.org/WRONG
"dead"
url: http://www.oecd.org/pisa/test/
var: (no-catch error (("Process www.oecd.org<1> not running") "error in process filter: "))
"error"
Compilation finished at Sat Apr 2 19:42:11
[-- Attachment #1.5: Type: text/plain, Size: 945 bytes --]
Curiously, there is ‘no-catch’ in the CAR of ‘var’ contents, but
i was not able to find any mention of it in the Elisp reference
manual.
> (d) Is there a more idiomatic way to work w/ threads and
> ‘url-http’ (or async network connections, in general)?
[url-*.el overview, plus emacs-aio]
I hope to be able to study these Someday.
> Thank-you for any insight into this corner of Emacs Lisp!
[‘read-string’ in batch mode]
Thanks for the tip. It's good to see Emacs can be useful in
many different contexts.
--
Thien-Thi Nguyen -----------------------------------------------
(defun responsep (query) ; (2022) Software Libero
(pcase (context query) ; = Dissenso Etico
(`(technical ,ml) (correctp ml))
...)) 748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 219 bytes --]
next prev parent reply other threads:[~2022-04-03 0:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 14:01 trapping process filter error in a thread Thien-Thi Nguyen
2022-03-22 19:28 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-02 23:54 ` Thien-Thi Nguyen
2022-04-03 0:50 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-03-24 2:33 ` Felix Dietrich
2022-04-03 0:07 ` Thien-Thi Nguyen [this message]
2022-04-10 8:58 ` Felix Dietrich
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=8735ivkp18.fsf@gnuvola.org \
--to=ttn@gnuvola.org \
--cc=felix.dietrich@sperrhaken.name \
--cc=help-gnu-emacs@gnu.org \
/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.