all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Threads vs url-http
@ 2024-09-29  0:28 813gan
  2024-09-29  5:26 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: 813gan @ 2024-09-29  0:28 UTC (permalink / raw)
  To: emacs-devel@gnu.org

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

Hi.
I attempted to write thread-friendly wrapper around url-http and it appears to hang Emacs.
Am i doing something wrong or it's bug?

(require 'url-http)
(require 'url-parse)
(defun url-retrieve-thread (url)
"Wrapper around url-http that download `URL' without blocking main thread."
(let* ((parsed-url (if (url-p url) url (url-generic-parse-url url)))
(mut (make-mutex))
(cond-var (make-condition-variable mut))
(buf nil)
(cb (lambda (&rest _) (setq buf (current-buffer)) (with-mutex mut (condition-notify cond-var)) )) )
(url-http parsed-url cb nil)
(with-mutex mut
(condition-wait cond-var) )
buf))

Idea was to call it from thread. In most trivial case:
(make-thread (apply 'url-retrieve-thread "http://example.com" nil))

It makes Emacs unresponsive (even C-g does not work).
I tested it on Emacs 28.2 and once of recent development versions (emacs-31.0.50)

Happy Hacking!

[-- Attachment #2: Type: text/html, Size: 2090 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-30 12:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-29  0:28 Threads vs url-http 813gan
2024-09-29  5:26 ` Eli Zaretskii
2024-09-29 23:53   ` 813gan
2024-09-30  7:38     ` Michael Albinus
2024-09-30 12:22     ` Eli Zaretskii

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.