Force sleep to ignore interrupts

andychambers2002 at yahoo.co.uk andychambers2002 at yahoo.co.uk
Thu Sep 14 07:27:23 EDT 2006


Jeremy Sanders wrote:

> andychambers2002 at yahoo.co.uk wrote:
>
> > It works as I want when used in the main application thread.
> > That is, when you hit Ctr + C, it stops running.  However, if
> > the class that subclasses it, also subclasses Thread, it breaks
> > in that hitting Ctrl + C interrupts the call to sleep which puts
> > the event loop out of sync with real time.
>
> Maybe you could install a signal handler to ignore ctrl+c, when required
>
> import signal
> signal.signal(signal.SIGINT, signal.SIG_IGN)

That worked nicely.  Thanks

Andy




More information about the Python-list mailing list