From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: trapping process filter error in a thread Date: Sat, 02 Apr 2022 20:07:31 -0400 Message-ID: <8735ivkp18.fsf@gnuvola.org> References: <87pmmegk7a.fsf@gnuvola.org> <87k0ckt6y9.fsf@sperrhaken.name> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23263"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Felix Dietrich Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 03 02:09:22 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nano2-0005se-CY for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 03 Apr 2022 02:09:22 +0200 Original-Received: from localhost ([::1]:41696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nano0-0004zZ-UN for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 02 Apr 2022 20:09:20 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nanmW-0004z9-90 for help-gnu-emacs@gnu.org; Sat, 02 Apr 2022 20:07:48 -0400 Original-Received: from delivery.mailspamprotection.com ([185.56.85.142]:47129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nanmU-000821-8S for help-gnu-emacs@gnu.org; Sat, 02 Apr 2022 20:07:47 -0400 Original-Received: from 241.110.209.35.bc.googleusercontent.com ([35.209.110.241] helo=giow1035.siteground.us) by se21.mailspamprotection.com with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1nanmO-0006nn-Dv; Sat, 02 Apr 2022 19:07:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnuvola.org ; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tpj/q0Fq7cn5uSDUvgPV10sqtSeqLtk6vYXo5PSM4d8=; b=SfrZt2+g8+eC39KKMbxG25cTXW LivzuYo8Dc9Dre5YfYrOWAQUZnKd264z1tK11mHR69f2bQ7LAzPlv3jT9wNIbtRvEJ+M1gZqKubhF U+TyGURPCUve3dnJ/KkSuenCYWWphdTUR0DqvFGOmRGz/MFt9TdUlgGgM+B4xUDQpJfU=; Original-Received: from [50.89.166.226] (port=43272 helo=abolire) by giow1035.siteground.us with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.90-.1) (envelope-from ) id 1nanmO-000MWC-2R; Sun, 03 Apr 2022 00:07:40 +0000 In-Reply-To: <87k0ckt6y9.fsf@sperrhaken.name> (Felix Dietrich's message of "Thu, 24 Mar 2022 03:33:50 +0100") X-Originating-IP: 35.209.110.241 X-SpamExperts-Domain: giow1035.siteground.us X-SpamExperts-Username: 35.209.110.241 Authentication-Results: mailspamprotection.com; auth=pass smtp.auth=35.209.110.241@giow1035.siteground.us X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.19) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT9IuG0rfCe/Xod172CsQ0JMPUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5yFxTiM0+JL8AduhP3LugoyJf62BJtE0fskIiXxk321KGr6 1V/UGvvo0RqjFyfD6Xiua2v8m/a8aUilWzFnKgvkPumU89c8OaxcWLmp7ynpEt8GtWlepEJ0yuo/ fNu5prjasE0yYSwoSJtDBJTXEF44KAzyKQ7CsKMkyLovgIkSS2sS60iMogHnX0iUChsY0rLP2gUQ v3SVBI1XHS9eOeVCqOWPUHeE/EGBsk9hLPKGAS7/+fOTvqVqTiiM4NskccTQ5mCi/LPumdQGHN7x Xvzl9mwSGfNaBmafifTJSMMwOH75IHefrt4A8X/Xytq/2cHcjNWYY9Jhwjc/H4SLVZROIY9eSmks 3lXG/rSOzA/y0+v7BUn/3e8RkeVKNu5WEt2FSXmMr44fp2SjrxH6WSufcd3QbXHil9nVohJvu6B5 vcQRHhpp7PEHhQA50A06366XcCwMG6OPDsYKCBdX/ClMWzvrlqr/siF7kmk0RghWw4zIacMilJyG VyjpEgOg2D/ZarYidkZBdHCCngOK96nKw3qNhf+deQvJCdEKHScH65hRrOZZqMOoDs1PwmznbNIB IkUL/j1Y48GvmeURQjjEO3qOOvb7xmtYjyCNCgISxUoLldE6gvbeQcfbAZNCT7mOxUmHH9uv3Njf gY0QaW27FDVST/zeKxg/qMuFiqK9NZa1RJ38q20VcjxMxHe13ImDh//lcZxhhxeFmMwLY3P812as nTpvMZeKkMKuTC+ajIdQ+XRP+J80d X-Report-Abuse-To: spam@quarantine1.mailspamprotection.com Received-SPF: pass client-ip=185.56.85.142; envelope-from=ttn@gnuvola.org; helo=delivery.mailspamprotection.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136833 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Felix Dietrich () Thu, 24 Mar 2022 03:33:50 +0100 > would like to use Emacs' threads and =E2=80=98url-http=E2=80=99 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=CA=BCs 27.1), but it does not appear to have anything to do with threads: it happens just as well when you call =E2=80=98func=E2=80=99 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 =E2=80=98command-error-function=E2=80=99 in the Ema= cs Lisp manual [...]. Good eye! I have managed to adapt your code fragment to produce a bad.el (attached here): --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=bad.el Content-Transfer-Encoding: quoted-printable (defvar url (or (car command-line-args-left) "http://www.oecd.org/pisa/test/")) (require 'url-http) (defun url-http-head (url) (let ((url-request-method "HEAD") (url-request-data nil)) (url-retrieve-synchronously url t t 8))) (setq url-debug nil ;; 1 command-error-function (lambda (data context caller) ;;(message "c-e-f:\ndata: %S\ncontext: %S\ncaller: %S" data context call= er) (when (and (eq 'url-http caller) (eq 'error (car data))) (throw (car data) (list (cdr data) context))))) (defun func () (let ((noninteractive t)) (condition-case var (if (url-http-file-exists-p url) "ok" "dead") (t (message "var: %S" var) "error")))) (defvar thread (make-thread 'func)) (message "%S" (thread-join thread)) --=-=-= Content-Type: text/plain that is able to trap the error (see bad.out, here): --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=bad.out Content-Transfer-Encoding: base64 LSotIG1vZGU6IGNvbXBpbGF0aW9uOyBkZWZhdWx0LWRpcmVjdG9yeTogIi90bXAvIiAtKi0KQ29t cGlsYXRpb24gc3RhcnRlZCBhdCBTYXQgQXByICAyIDE5OjQyOjA4Cgpmb3IgdXJsIGluIGh0dHBz Oi8vd3d3LmdudS5vcmcvIGh0dHBzOi8vd3d3LmdudS5vcmcvV1JPTkcgaHR0cDovL3d3dy5vZWNk Lm9yZy9waXNhL3Rlc3QvIDsgZG8gcHJpbnRmICdcbnVybDogJXNcbicgJHVybCA7IGVtYWNzIC1i YXRjaCAtUSAtbCBiYWQuZWwgJHVybCA7IGRvbmUKCnVybDogaHR0cHM6Ly93d3cuZ251Lm9yZy8K Im9rIgoKdXJsOiBodHRwczovL3d3dy5nbnUub3JnL1dST05HCiJkZWFkIgoKdXJsOiBodHRwOi8v d3d3Lm9lY2Qub3JnL3Bpc2EvdGVzdC8KdmFyOiAobm8tY2F0Y2ggZXJyb3IgKCgiUHJvY2VzcyB3 d3cub2VjZC5vcmc8MT4gbm90IHJ1bm5pbmciKSAiZXJyb3IgaW4gcHJvY2VzcyBmaWx0ZXI6ICIp KQoiZXJyb3IiCgpDb21waWxhdGlvbiBmaW5pc2hlZCBhdCBTYXQgQXByICAyIDE5OjQyOjExCg== --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Curiously, there is =E2=80=98no-catch=E2=80=99 in the CAR of =E2=80=98var= =E2=80=99 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 > =E2=80=98url-http=E2=80=99 (or async network connections, in gener= al)? [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! [=E2=80=98read-string=E2=80=99 in batch mode] Thanks for the tip. It's good to see Emacs can be useful in many different contexts. =2D-=20 Thien-Thi Nguyen ----------------------------------------------- (defun responsep (query) ; (2022) Software Libero (pcase (context query) ; =3D Dissenso Etico (`(technical ,ml) (correctp ml)) ...)) 748E A0E8 1CB8 A748 9BFA =2D-------------------------------------- 6CE4 6703 2224 4C80 7502 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iG4EARECAC4WIQR0jqDoHLinSJv6bORnAyIkTIB1AgUCYkjlRRAcdHRuQGdudXZv bGEub3JnAAoJEGcDIiRMgHUCqwAAnjN5fW8PfA5rl6+Q2HCvpr+EYCrfAKCA0eMN JCF19v5qU2jnNh92V63YKA== =y7It -----END PGP SIGNATURE----- --==-=-=--