On Tue, 3 Jul 2007, seth vidal wrote:

On Tue, 2007-07-03 at 08:42 -0400, Konstantin Ryabitsev wrote:
Hi, all:

Just a reminder that it's still impossible to exit yum using Ctrl-C or
Ctrl-\. It always just switches to a different mirror, no matter how
quickly or frequently I press ctrl-c or ctrl-\. I believe it was
claimed "fixed" several times in the past, but it still is not working
as of 3.2.1. This means that if you're using mirrorlists, yum is
near-impossible to exit.

There should be a way to interrupt yum, at least during
package/metadata download. That's very basic functionality, and it is
missing. Having to Ctrl-z and then kill -9 is not very friendly to
users nor admins.


okay, I'm open to suggestions. The last time we stepped around the
problem using menno's work for an opportunistic access to the rpmdb it
was purported that we were corrupting the rpmdb. That may or may not
have turned out to be the case as there was another kernel mmap issue at
the same time. However, I'm game to figuring out ways of fixing this
issue w/o waiting for rpm modifications to occur.

After spending several days of looking at various ways to deal with this, I'm back to what Jeff has been suggesting all along: expose two signal related things out of rpmlib to python and check for caught signals where needed.

It needs a small yum modification (see below for the patch), seems to be unavoidable. The below patch assumes rpm.sqCaught() is passed a list of signals to be checked and returns a list of matched ones. I already have the code to do this, it just needs a bit more sanity checks. The question is do you want it that way or just sqCaught(signum) - the latter would much less code in the bindings ;)

BTW it'd be just as well to just call rpm.checkSignals() without any conditionals there, the additional sqCaught() check will give you a hint whether to expect checkSignals() to exit or not (but that can't be relied on as signals can occur in between)

So, what say you - should we finally fix the ctrl-c problem?

        - Panu -

Index: output.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/output.py,v
retrieving revision 1.79
diff -u -r1.79 output.py
--- output.py   28 Jun 2007 15:37:01 -0000      1.79
+++ output.py   19 Jul 2007 14:21:56 -0000
@@ -20,6 +20,8 @@
 import sys
 import time
 import logging
+import rpm
+import signal
 from i18n import _

 from urlgrabber.progress import TextMeter
@@ -28,6 +30,13 @@

 from yum import logginglevels

+class YumTextMeter(TextMeter):
+    def update(self, amount_read, now=None):
+        caught = rpm.sqCaught([signal.SIGINT, signal.SIGTERM])
+        if caught:
+            rpm.checkSignals()
+        TextMeter.update(self, amount_read, now)
+
 class YumOutput:

     def __init__(self):
@@ -329,7 +338,7 @@
             self.repos.setProgressBar(None)
             self.repos.callback = None
         else:
-            self.repos.setProgressBar(TextMeter(fo=sys.stdout))
+            self.repos.setProgressBar(YumTextMeter(fo=sys.stdout))
             self.repos.callback = CacheProgressCallback()

         # setup our failure report for failover
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to