title: Query whether Python's threading.Lock is locked or not
body: <p>I have a thread I am running (code below) which launches a blocking subprocess. To ensure that other threads do not launch the same subprocess, I have a lock around this <code>subprocess.call</code> call. I also want to be able to terminate this subprocess call, so I have a stop function which I call from somewhere else. In the event that the subprocess is stopped prematurely, I want to release the lock as well, which is what the below code does:</p>
  
  <pre><code>class SomeThread(threading.Thread):
     def run(self):
        aLock.acquire()
        self.clip = subprocess.call([ 'mplayer', 'Avatar.h264'], stdin=subprocess.PIPE)
        aLock.release()
     def stop(self):
        if self.clip != None and self.clip.poll() == True:
           try:
              self.clip.send_signal(signal.SIGINT)
           except:
              pass
        aLock.release()
  </code></pre>
  
  <p>However, according to the documentation <a href="http://docs.python.org/2/library/threading.html#lock-objects" rel="noreferrer">here</a>, calling <code>release()</code> on a released lock will raise an Exception:</p>
  
  <pre><code>A RuntimeError is raised if this method is called when the lock is unlocked.
  </code></pre>
  
  <p>Is there a query function like <code>aLock.isLocked()</code>?</p>