title: Garbage collection of object after exception
body: <p>I have observed that after an exception I have an object for which constructor is not called, which causes a lock to be held. What is the best way to improve the situation? Would calling del in an except block be the solution?</p>
  
  <pre><code>b=BigHash(DB_DIR, url)
  meta = bdecode(b.get())
  return meta
  </code></pre>
  
  <p>b holds a lock which is released on destruction (it's a C++ object)
  an exception is thrown by b.get().</p>