public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Stefan Raspl <raspl@linux.vnet.ibm.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, frankja@linux.vnet.ibm.com
Subject: Re: [PATCH v2 03/17] tools/kvm_stat: handle SIGINT in log and batch modes
Date: Wed, 15 Mar 2017 22:54:40 +0100	[thread overview]
Message-ID: <20170315215440.GJ14081@potion> (raw)
In-Reply-To: <20170310124016.96319-4-raspl@linux.vnet.ibm.com>

2017-03-10 13:40+0100, Stefan Raspl:
> SIGINT causes ugly unhandled exceptions in log and batch mode, which we
> prevent by catching the exceptions accordingly.
> 
> Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
> ---

The interactive mode also gets

  Exception KeyboardInterrupt in <bound method Event.__del__ of <__main__.Event object at 0x7f09a3c2cd50>> ignored

If you press ^C twice fast :)

>  tools/kvm/kvm_stat/kvm_stat | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
> index ef47ad7..14536c0 100755
> --- a/tools/kvm/kvm_stat/kvm_stat
> +++ b/tools/kvm/kvm_stat/kvm_stat
> @@ -969,12 +969,15 @@ class Tui(object):
>  
>  def batch(stats):
>      """Prints statistics in a key, value format."""
> -    s = stats.get()
> -    time.sleep(1)
> -    s = stats.get()
> -    for key in sorted(s.keys()):
> -        values = s[key]
> -        print '%-42s%10d%10d' % (key, values[0], values[1])
> +    try:
> +        s = stats.get()
> +        time.sleep(1)
> +        s = stats.get()
> +        for key in sorted(s.keys()):
> +            values = s[key]
> +            print '%-42s%10d%10d' % (key, values[0], values[1])
> +    except KeyboardInterrupt:
> +        pass
>  
>  def log(stats):
>      """Prints statistics as reiterating key block, multiple value blocks."""
> @@ -991,11 +994,14 @@ def log(stats):
>      line = 0
>      banner_repeat = 20
>      while True:
> -        time.sleep(1)
> -        if line % banner_repeat == 0:
> -            banner()
> -        statline()
> -        line += 1
> +        try:
> +            time.sleep(1)
> +            if line % banner_repeat == 0:
> +                banner()
> +            statline()
> +            line += 1
> +        except KeyboardInterrupt:
> +            break
>  
>  def get_options():
>      """Returns processed program arguments."""
> -- 
> 2.8.4
> 

  reply	other threads:[~2017-03-15 21:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 12:39 [PATCH v2 00/17] tools/kvm_stat: Misc Patches Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 01/17] tools/kvm_stat: hide cursor Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 02/17] tools/kvm_stat: catch curses exceptions only Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 03/17] tools/kvm_stat: handle SIGINT in log and batch modes Stefan Raspl
2017-03-15 21:54   ` Radim Krčmář [this message]
2017-03-10 12:40 ` [PATCH v2 04/17] tools/kvm_stat: fix misc glitches Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 05/17] tools/kvm_stat: fix trace setup glitch on field updates in TracepointProvider Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 06/17] tools/kvm_stat: full PEP8 compliance Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 07/17] tools/kvm_stat: reduce perceived idle time on filter updates Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 08/17] tools/kvm_stat: document list of interactive commands Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 09/17] tools/kvm_stat: display guest name when using pid filter Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 10/17] tools/kvm_stat: remove pid filter on empty input Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 11/17] tools/kvm_stat: print error messages on faulty pid filter input Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 12/17] tools/kvm_stat: display regex when set to non-default Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 13/17] tools/kvm_stat: remove regex filter on empty input Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 14/17] tools/kvm_stat: add option '--guest' Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 15/17] tools/kvm_stat: add interactive command 'c' Stefan Raspl
2017-03-10 12:40 ` [PATCH v2 16/17] tools/kvm_stat: add interactive command 'r' Stefan Raspl
2017-03-15 21:53   ` Radim Krčmář
2017-03-10 12:40 ` [PATCH v2 17/17] tools/kvm_stat: add '%Total' column Stefan Raspl
2017-03-15 21:52   ` Radim Krčmář
2017-03-15 21:36 ` [PATCH v2 00/17] tools/kvm_stat: Misc Patches Radim Krčmář
2017-03-17  7:08   ` Stefan Raspl

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

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

  git send-email \
    --in-reply-to=20170315215440.GJ14081@potion \
    --to=rkrcmar@redhat.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=raspl@linux.vnet.ibm.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox