title: Python sharing a lock between processes
body: <p>I am attempting to use a partial function so that pool.map() can target a function that has more than one parameter (in this case a Lock() object).</p>
  
  <p>Here is example code (taken from an answer to a previous question of mine):</p>
  
  <pre><code>from functools import partial
  
  def target(lock, iterable_item):
      for item in items:
          # Do cool stuff
          if (... some condition here ...):
              lock.acquire()
              # Write to stdout or logfile, etc.
              lock.release()
  
  def main():
      iterable = [1, 2, 3, 4, 5]
      pool = multiprocessing.Pool()
      l = multiprocessing.Lock()
      func = partial(target, l)
      pool.map(func, iterable)
      pool.close()
      pool.join()
  </code></pre>
  
  <p>However when I run this code, I get the error:</p>
  
  <pre><code>Runtime Error: Lock objects should only be shared between processes through inheritance.
  </code></pre>
  
  <p>What am I missing here? How can I share the lock between my subprocesses?</p>