merge 675064 679975 tags 679975 + patch thanks Hi,
The way to act when a user hits Ctrl-C repeatedly is *not* to say "screw
you, dear user, I'm going to continue lying and say that I'll quit in a
few seconds". I've had cases where offlineimap would hang for several
minutes after a Ctrl-C, which is *extremely* annoying.
These two bug reports have been open for several years now, and nothing
has happened with them, which is very disappointing.
It's not hard:
--- offlineimap-6.5.5.orig/offlineimap/init.py
+++ offlineimap-6.5.5/offlineimap/init.py
@@ -22,6 +22,7 @@ import offlineimap.imaplib2 as imaplib
import signal
import socket
import logging
+import time
from optparse import OptionParser
import offlineimap
from offlineimap import accounts, threadutil, syncmaster
@@ -344,6 +345,10 @@ class OfflineImap:
getglobalui().warn("Terminating NOW (this may "\
"take a few seconds)...")
accounts.Account.set_abort_event(self.config, 3)
+ if self.last_sigterm > time.time() - 3:
+ getglobalui().warn("OK, OK, Aborting!\n")
+ os.abort()
+ self.last_sigterm = time.time()
elif sig == signal.SIGQUIT:
stacktrace.dump (sys.stderr)
os.abort()
The message could say something like "(but it's your fault if you lose
data)", if you like. It could shut down in a slightly more graceful way
(e.g., kill network connections uncleanly, but try to close local files
properly). It could add a counter so that it happens after three Ctrl-C
keystrokes rather than one, if needs be. If the reason the message
exists is so that you don't lose data, I would kindly request that you
stop fussing about that; I don't think there's anything that can happen
which could not be resolved with a simple "rm -rf ~/.offlineimap
~/Maildir; offlineimap".
In the three years since this misfeature was introduced, it's become a
habit for me to hit Ctrl-Z followed by "kill -9 %1" as a way to stop
offlineimap whenever I see that "Terminating NOW" message. That can't
have been the intention...
Thanks,
--
It is easy to love a country that is famous for chocolate and beer
-- Barack Obama, speaking in Brussels, Belgium, 2014-03-26
signature.asc
Description: Digital signature

