unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 45117@debbugs.gnu.org
Subject: bug#45117: 28.0.50; process-send-string mysteriously exiting non-locally when called from timer
Date: Thu, 10 Dec 2020 21:16:00 +0000	[thread overview]
Message-ID: <878sa51hwv.fsf@gmail.com> (raw)
In-Reply-To: <jwvtusts8u0.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 10 Dec 2020 15:43:16 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> No, I was no presuming such a simple model, actually.  I was really
>>> thinking about "send data to the LSP server then get some answer
>>> a second or more later".
>> Right, so in LSP it's perfectly possible to send three requests in a
>> row, say reqX, reqY and reqZ and get three replies in a completely
>> different order repZ, repX, repY.  How to you match each reply to each
>> request?
>
> I assume there's some "request-id" mechanism.  Not sure what this has to
> do with this discussion, OTOH.

Right, a request-id mechanism.  The request must be registered
atomically with process_send_string.  If you interrupt in between, you
have inconsistent requests (either registered request-id's for which no
actual request was fired, or requests which were fired for which no
request-id's were registered).  Client code can detect/prevent these
interruptions, but it's clumsy.  And may cost the dev many hours to
understand what is up.  Shouldn't be default IMO.

>> process_send_string may send things in "bunches", I read in the
>> docstring, but it will not (and should not) be interrupted.
>
> Indeed, I believe it should not be aborted in the middle by
> `while-no-input` (it would be a bug, because the `process-send-string`
> API doesn't offer any way to know what has been or hasn't been sent in
> that case).

Agree.

>> But that is not always so.  And I think it's too eager of ElDoc to try
>> to do that so early and so brutally.  It's better to leave it to the
>> callback handlers, which we have now.  That's a much safer spot to
>> know if the answer we just got still makes sense.  Or if we're in
>> a hurry, we let the backend know asap.
>
> You might be right: the result of the current request sent to the LSP
> could still be useful for the next eldoc-idle-time cycle, indeed.

Yes, it's only an heuristic.

>>> The contract is different for timer functions than it is for eldoc
>>> functions, yes.  This is because the expectation is that eldoc functions
>>> may run for a non-negligible amount of time.
>> Why do you have that expectation?  Any particular example in the wild?
> Good question.

:-)

>> It was, after all, the status quo after you changed it for 27.1.
>> Perhaps you had a rationale?
>
> I probably did, but ... can't remember and wasn't clever enough to write
> it in the commit message :-(
> Maybe to accommodate those backends which needed async operation but had
> to live within the confines of the previously limited eldoc API?

Likely, yes.  But which one of those were the "blocking" type?  Because
even with the limited API, SLY/SLIME were just calling eldoc-message
from the process filter. Which is equivalent to what we have now in
terms of sync.  In fact, to keep backward compatibility, I haven't
touched this part of SLY at all.  Anyway, you must have done it for some
other slow synchronous, wait-for-the-retval backend.  That hypothetical
backend will hurt if we take back the while-no-input.  OTOH that
hypothetical backend can now upgrade to a much better API.

> Maybe the maintainer of eldoc.el will prefer to undo this change,
> then ;-) ?

Who's that? ;-) But OK, eldoc.el is now distributable independently so
we have good defense against this.

João





  parent reply	other threads:[~2020-12-10 21:16 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 11:44 bug#45117: 28.0.50; process-send-string mysteriously exiting non-locally when called from timer João Távora
2020-12-08 15:39 ` Eli Zaretskii
2020-12-08 15:56   ` João Távora
2020-12-08 17:01     ` Eli Zaretskii
2020-12-08 17:05       ` João Távora
2020-12-09 11:24       ` João Távora
2020-12-09 15:33         ` Eli Zaretskii
2020-12-10 15:00           ` João Távora
2020-12-10 15:23             ` Eli Zaretskii
2020-12-10 16:15               ` João Távora
2020-12-10 16:29                 ` João Távora
2020-12-10 17:20                   ` Dmitry Gutov
2020-12-10 17:51                   ` Stefan Monnier
2020-12-10 18:05                     ` João Távora
2020-12-10 18:37                       ` Stefan Monnier
2020-12-10 18:48                         ` Eli Zaretskii
2020-12-10 18:50                         ` João Távora
2020-12-10 19:44                           ` Eli Zaretskii
2020-12-10 19:47                             ` João Távora
2020-12-10 19:55                               ` Eli Zaretskii
2020-12-10 19:58                                 ` João Távora
2020-12-10 20:14                                   ` Eli Zaretskii
2020-12-10 20:15                                     ` João Távora
2020-12-10 20:37                                     ` Dmitry Gutov
2020-12-10 19:46                           ` Stefan Monnier
2020-12-10 20:12                             ` João Távora
2020-12-10 20:43                               ` Stefan Monnier
2020-12-10 20:55                                 ` Dmitry Gutov
2020-12-10 22:48                                   ` Stefan Monnier
2020-12-10 21:16                                 ` João Távora [this message]
2020-12-10 22:58                                   ` João Távora
2020-12-11  7:31                                 ` Eli Zaretskii
2020-12-11 14:31                                   ` Stefan Monnier
2020-12-11 14:40                                     ` Eli Zaretskii
2020-12-11 14:43                                       ` João Távora
2020-12-11 14:41                                     ` João Távora
2020-12-11 14:50                                       ` Stefan Monnier
2020-12-13 23:19                                         ` João Távora
2020-12-14  0:35                                           ` Stefan Monnier
2020-12-10 16:41                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sa51hwv.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=45117@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).