Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt fixing :sync #99

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions request.el
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ temporary file paths."
files))

(cl-defun request--curl (url &rest settings
&key type data files headers timeout response
&key type data files headers timeout response semaphore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "semaphore" a standard name for this kind of process watcher?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No? But "semaphore" is exactly what it is.

&allow-other-keys)
"cURL-based request backend.

Expand Down Expand Up @@ -1048,7 +1048,9 @@ removed from the buffer before it is shown to the parser function.
(process-put proc :request-response response)
(set-process-coding-system proc 'binary 'binary)
(set-process-query-on-exit-flag proc nil)
(set-process-sentinel proc #'request--curl-callback)))
(set-process-sentinel proc #'request--curl-callback)
(when semaphore
(add-function :after (process-sentinel proc) semaphore))))

(defun request--curl-read-and-delete-tail-info ()
"Read a sexp at the end of buffer and remove it and preceding character.
Expand Down Expand Up @@ -1169,11 +1171,14 @@ START-URL is the URL requested."
;; `call-process'.
(let (finished)
(prog1 (apply #'request--curl url
:complete (lambda (&rest _) (setq finished t))
:semaphore (lambda (&rest _) (setq finished t))
settings)
(let ((proc (get-buffer-process (request-response--buffer response))))
(while (and (not finished) (request--process-live-p proc))
(accept-process-output proc))))))
(with-local-quit
(while (not finished)
(if (request--process-live-p proc)
(accept-process-output proc)
(sleep-for 0 300))))))))

(defun request--curl-get-cookies (host localpart secure)
(request--netscape-get-cookies (request--curl-cookie-jar)
Expand Down