Subject: Re: bug#39187: Fwd: "Package refresh is already in progress, please wait..."

From: Stefan Kangas <[email-masked]>
Date: Thu, 23 Jan 2020 19:18:28 +0100

>> > It looks like emacs does not properly handle package refreshes when
>> > the internet connection has been killed in the middle of an
>> > refresh.
>> > 
>> > I often get this message in that case and I can't call package
>> > until I actually kill emacs and restart it.
[...]
> I think the fix here is simply to make sure that these processes times
> out.

Unless I'm missing something, it turns out that this is not that easy
to do.  At least I couldn't figure out how to do it.  I found the
following probably relevant bug:

 bug#34607: url-retrieve-synchronously: TIMEOUT option value takes no effect

For now at least, I'm giving up on finding a solution where url does
the right thing and times out. 

-----

I see two ways forward:

1. Remove the warning and accept that we might launch several
   processes doing the same update one after the other.  I would like
   to avoid that on master, but it might be the least intrusive change
   for emacs-27.
  
2. When we run a refresh, save the current time.  If the user tries to
   run another refresh, check if more than X seconds has elapsed since
   the old one was started.  If it has been more than X seconds,
   prompt the user to kill the old refresh and re-launch it.  It won't
   be perfect, but it will be better than what we had before at least.

Does anyone else have any ideas or preferences here?  Otherwise, I'll
revert the change that exposed this bug on the emacs-27 branch, and
implement the second change on master.

Best regards,
Stefan Kangas