title: Share a resource between two processes
body: <p>I want to know the best practices followed <strong>to share a queue (resource)</strong> between two processes in Python. Here is a what each process is doing:</p>
  
  <p><strong>Process_1:</strong> continuously gets data (in json format) from a streaming api</p>
  
  <p><strong>Process_2:</strong> is a daemon (similar to Sander Marechal's <a href="http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/" rel="nofollow">code</a>) which commits data (one at a time) into a database</p>
  
  <p>So, <strong>Process_1</strong> (or Producer) puts a unit of data onto this shared resource, and <strong>Process_2</strong> (or Consumer) will poll this shared resource for any new units of data, and store them in a DB, if any.</p>
  
  <p>There are some options which came to my mind:</p>
  
  <ul>
  <li>Using pickle (drawback: extra overhead of pickling and de-pickling)</li>
  <li>Passing data via <code>stdout</code> of Process_1
  to <code>stdin</code> of Process_2 (drawback: none, but not sure how to implement this with a daemon)</li>
  <li>Using the <code>pool</code> object in the <code>multiprocessing</code> library (drawback: not sure how to code this as one process is a daemon)</li>
  </ul>
  
  <p>I would like an optimal solution practiced in this regard, with some code :). Thanks.</p>