Quoting Hal Murray <[email protected]>:
[email protected] said:
Does python have an option to just exit with the sigint   signal handler and
not rely on the interpreter state?

That works for "ntpq -p", but there are two cases in ntpq where that isn't
good enough.

One is when running in interactive mode.  I suppose that could be fixed by
running each command in a separate thread.  If ^C happens, kill that thread
and ignore it.

The other is the mrulist command.  It's two loops.  One to collect the info
and another to print it out.  (there may be a sort in between)  ^C during the
first loop is supposed to stop collecting, then print what has been collected.

So, one way to fix this would be to use a library that calls poll/select from python, and interruptions are returned back into python.

For instance: http://www.dnspython.org/

Downside is that it takes more code to do the lookup:

import dns.resolver

a_records = dns.resolver.query("example.com","A")
aaaa_records = dns.resolver.query("example.com","AAAA")
# merge A/AAAA records here.


Upside is ^C works properly:

^C Traceback (most recent call last):
...
  File "/usr/lib/python2.7/site-packages/dns/query.py", line 70, in _poll_for
    event_list = pollable.poll(long(timeout * 1000))
KeyboardInterrupt


_______________________________________________
devel mailing list
[email protected]
http://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to