-
Notifications
You must be signed in to change notification settings - Fork 11
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
Emacs process sentinel-related issues #3
Comments
@niklaseklund If you are encountering this problem or one related to it, please provide more information to improve the chances of solving it. FYI, to anyone reading this, the issues mentioned here don't seem to be problematic in practice. Ement.el, |
Small update: In looking at CI results lately, it seems that the current Emacs snapshot version may have improved on this problem slightly in that sometimes all of the tests pass (however, note that the linting pass fails due to changes in the |
Have just had a possible insight into this problem: In the following source code: (defun hyperdrive-entry-at (version entry)
"Return ENTRY at its hyperdrive's VERSION, or nil if not found."
;; Use `hyperdrive-copy-tree', because `copy-tree' doesn't work on
;; records/structs, and `copy-hyperdrive-entry' doesn't copy deeply,
;; and we need to be able to modify the `etc' alist of the copied
;; entry separately.
(let ((entry (hyperdrive-copy-tree entry t)))
(setf (alist-get 'with-version-p (hyperdrive-entry-etc entry)) (and version t))
(when version
(setf (hyperdrive-entry-version entry) version))
(condition-case err
(hyperdrive-fill entry :then 'sync)
(plz-http-error
(pcase (plz-response-status (plz-error-response (caddr err)))
(404 nil)
(_ (signal (car err) (cdr err))))))))
(cl-defun hyperdrive-fill
(entry &key queue then
(else (lambda (plz-error)
;; FIXME: Use a message instead of a warning for
;; now, because the 404 errors for filenames with
;; spaces are annoying as warnings.
(hyperdrive-message (format "hyperdrive-fill: error: %S" plz-error) )
;; (display-warning 'hyperdrive
;; (format "hyperdrive-fill: error: %S" plz-error))
)))
"Fill ENTRY's metadata and call THEN.
If THEN is `sync', return the filled entry and ignore ELSE.
Otherwise, make request asynchronously and call THEN with the
filled entry; or if request fails, call ELSE (which is passed to
`hyperdrive-api', which see. If QUEUE, make the fill request in
the given `plz-queue'"
(declare (indent defun))
(pcase then
('sync (hyperdrive--fill entry
(plz-response-headers
(with-local-quit
(hyperdrive-api 'head (hyperdrive-entry-url entry)
:as 'response
:then 'sync
:noquery t)))))
(_ (hyperdrive-api 'head (hyperdrive-entry-url entry)
:queue queue
:as 'response
:then (lambda (response)
(funcall then (hyperdrive--fill entry (plz-response-headers response))))
:else else
:noquery t)))) When stepping through
(Note the |
Today, thanks to @josephmturner's help, I finally put together this puzzle piece from the Info page
I wrote a post to emacs-devel about the issue, asking for guidance and whether Emacs should be patched to change this behavior: https://lists.gnu.org/archive/html/emacs-devel/2023-05/msg00251.html In that message I also noted how request.el handles this issue, and a potential workaround. |
There is absolutely some sort of issue with process handling in Emacs, at least when in batch mode. I've been developing some tools with the heavy use of In my case, I found that the following code I hacked together helps:
What this does is modify This one misbehavior I have found with the solution completely solved my issues in my projects. If this helps get you at least a bit further that would be great. |
@piknik Wow, thanks for sharing that. Did you report an Emacs bug with that info and code? Also, what versions of Emacs did you see that behavior on? I don't think I've seen that exact problem in my projects, so I wonder if it's been fixed since then. AFAIK Emacs 27 and/or 28 had some minor fixes in Although, I'm not completely sure if I haven't seen that problem. My current intuition is that, when I update |
@alphapapa I haven't run into any issue specifically when errors are invoked or caught in a sentinel. In fact, my projects have a nested sentinel call stack, where sentinels can make other processes and handle errors from them. I believe that the C code hands off execution to elisp in the I'm using I am not familiar with the Emacs bug reporting process and have never submitted Emacs bugs. Would I be right to follow the EmacsWiki entry on Emacs Bug Tracker? |
Hm, well, IIUC that's maybe not a good idea. See my recent post to emacs-devel and Eli Zaretskii's reply: https://lists.gnu.org/archive/html/emacs-devel/2023-05/msg00251.html He says that one should definitely not signal errors from inside a sentinel, which I would presume would apply to anything called from a sentinel, i.e. the whole call stack.
This is basically described in the Elisp manual section 39.10 on process sentinels. But even that has a limit on how much detail it goes into.
Hm, that does sound similar to the problems I've experienced.
Maybe, but the EmacsWiki is not an official resource and may be outdated or incorrect. Basically, the thing to do is |
Interesting. With my use case of Emacs primarily in batch mode, I have a custom debugger that requires This behavior still doesn't explain why the sentinel sometimes runs before the final filter call. At some point I'll look into
Thanks for the info |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@piknik FWIW, I've made some changes in a branch that seem to solve the problem of sometimes getting a nil return value from a I intend for that branch to be a future version of plz; after it's merged I'll let it mellow on |
This seems to be fixed in v0.7 and on |
AFAIK this is solved now, so closing. |
See also:
The text was updated successfully, but these errors were encountered: