Subject: Re: bug#49682: 27.2.50; accept-process-output within accept-process-output hangs emacs

From: Eli Zaretskii <[email-masked]>
Date: Mon, 06 Nov 2023 19:39:53 +0200

> Date: Mon, 06 Nov 2023 11:14:18 -0600
> From: LdBeth <[email-masked]>
> 
> This bug seems happened many times to me (on Emacs 29.1 macOS, with
> Mitsuharu's patches if that matters) whenever I open an multipart
> email that contains HTML that has several image links through IMAP in
> the Wanderlust email reader since I start to enable HTML images in the
> email reader. (And for some reason C-g seems not able to interrupt the
> hang)
> 
> The shr library uses url-queue to asynchronously download images
> and Wanderlust also use `accept-process-output' call to handle IMAP.
> 
> For this particular case I used a dirty hack
> 
> (define-advice accept-process-output
>     (:before (&rest _) sync-queue)
>   (when (fboundp 'url-queue-check-progress)
>     (funcall #'url-queue-check-progress)))
> 
> However, could we make `accept-process-output' atomic so
> the timer won't interrupt it? Or there is no reliable
> method yet to make any atomic operations in Emacs yet?

If a Lisp program wants to avoid timers during the call to
accept-process-output, could perhaps temporarily bind timer-list to
nil or something?