title: How to create a unique ID in a Python Class across multiple processes
body: <p>I want to write an object that, upon instantiation, generates a new ID for each instance. This ID however must be</p>
  
  <ul>
  <li>Generated in a thread and process safe manner</li>
  <li>Unique even across processes (spawned with multiprocessing)</li>
  </ul>
  
  <p>A few non-concerns:</p>
  
  <ul>
  <li>This particular object creation is not performance critical so the synchronization overhead posed by this is acceptable.</li>
  <li>IDs must not be serial, though a clean solution usually comes with that.</li>
  <li>We are ignorant enough to not care about python 2 at all.</li>
  </ul>
  
  <p>There are already some solutions which work only in <a href="https://stackoverflow.com/questions/1045344/how-do-you-create-an-incremental-id-in-a-python-class">one process</a>, the most elegant being the use of an <code>itertools.count()</code> object. Using <code>id()</code> is no option as it is not guaranteed to be unique. The ideal solution would probably to be a similar object to <code>itertools.count()</code> which holds some static global value across processes.</p>
  
  <p>Related discussion on our project: <a href="https://github.com/coala-analyzer/coala/issues/981" rel="nofollow noreferrer">https://github.com/coala-analyzer/coala/issues/981</a></p>