Python sleep function does not catch interrupt signal
<p>I cannot catch the INT signal in the main thread, please advise me how to fix the problem. I wish that the sleep method could be interrupted by CTRL+C, but it waits till the timer is ended..</p>

<pre><code>import pygtk
pygtk.require('2.0')

import gtk
import time
import urllib2
import re
import signal
import sys

import __main__

from time import ctime, strftime, localtime
from threading import Thread

myThread = None

class MyThread(Thread):

    def __init__(self, filename):
        Thread.__init__(self)
        self.filename = filename;
        self.terminate = False

    def StopProcess(self):
        self.terminate = True

    def run(self):
        while self.terminate &lt;&gt; True:
            time.sleep(5)
            self.terminate = True

def SignalHandler(signum, frame):
    if (myThread &lt;&gt; None):
        myThread.StopProcess()
    sys.exit()

if __name__ == "__main__":

    signal.signal(signal.SIGINT, SignalHandler)

    myThread = MyThread("aaa")
    myThread.start()
</code></pre>
