title: Python multiprocessing library misbehaving?
body: <p>So I am attempting to write a piece of code that allows python to control GPIO pins on a Raspberry Pi using a timer that runs concurrently with a main program.</p>
  <p>Here is a very simplified view of the code I am writing:</p>
  <pre><code>from multiprocessing import Process, Lock
  from time import sleep
  
  
  
  def motor_up(time, lock):
      lock.acquire()
      print(&quot;turn up PINS on&quot;)
      sleep(time)
      print(&quot;turn up PINS off&quot;)
      lock.release()
  
  def motor_down(time, lock):
      lock.acquire()
      print(&quot;turn down PINS on&quot;)
      sleep(time)
      print(&quot;turn down PINS off&quot;)
      lock.release()
  
  if __name__ == '__main__':
      motor_lock = Lock()
  
      time = 10
      up = Process(target=motor_up, args = (time, motor_lock))
      down = Process(target=motor_down, args = (time, motor_lock))
  
      up.start()
  
      sleep(4)
  
      down.start()
  </code></pre>
  <p>essentially the locks are supposed to stop the other process from running until the first one has finished, which means that this process should take at minimum 20 seconds to run.</p>
  <p>But when I run it a few weird things happen:</p>
  <ol>
  <li>it does not print &quot;turn up PINS on&quot; and then wait 10 seconds to print &quot;turn up PINS off&quot;.  it basically waits approximately 10 seconds, then prints both at the same time.</li>
  <li>it then waits about 10 seconds, and does the print statements for the other process in a similar fashion</li>
  </ol>
  <pre><code>turn up PINS on
  turn up PINS off
  turn down PINS on
  turn down PINS off
  [Finished in 20.151s]
  </code></pre>
  <p>I have no clue why this is happening, or how to fix it.  I am very new to multiprocessing.</p>
  <p>Any and all device is appreciated</p>