title: python lock with-statement and timeout
body: <p>I am using a Python 3 sequence like this:</p>
  
  <pre><code>lock = threading.Lock()
  res = lock.acquire(timeout=10)
  if res:
      # do something ....
      lock.release()
  else:
      # do something else ...
  </code></pre>
  
  <p>I would prefer to use a with-statement instead of explicit "acquire" and "release", but I don't know how to get the timeout effect.</p>