title: Terminate long running python threads
body: <p>What is the recommended way to terminate unexpectedly long running threads in python ? I can't use SIGALRM, since</p>
  
  <blockquote>
    <p>Some care must be taken if both
    signals and threads are used in the
    same program. The fundamental thing to
    remember in using signals and threads
    simultaneously is: always perform
    signal() operations in the main thread
    of execution. Any thread can perform
    an alarm(), getsignal(), pause(),
    setitimer() or getitimer(); <strong>only the
    main thread can set a new signal
    handler, and the main thread will be
    the only one to receive signals</strong>
    (this is enforced by the Python signal
    module, even if the underlying thread
    implementation supports sending
    signals to individual threads). This
    means that signals can’t be used as a
    means of inter-thread
    communication.Use locks instead.</p>
  </blockquote>
  
  <p>Update: each thread in my case blocks -- it is downloading a web page using urllib2 module and sometimes operation takes too many time on an extremely slow sites. That's why I want to terminate such slow threads</p>