title: Python - Global counter
body: <p>I am recursively generating few objects, which need a contiguous, unique id. How can I guarantee (easiest) the synchronization in python 2.7. </p>
  
  <pre><code>iid = 1
  
  def next_id():
      iid += 1
      return iid
  
  def process():
      # .. do something
      id = next_id()
  </code></pre>