title: Why is a Python multiprocessing daemon process not printing to standard output?
body: <p>I have been experimenting with multiprocessing, and running into a mindblock with daemons.</p>
  
  <p>I have one daemon and one non-daemon process, the daemon emitting output every one second indefinitely, while the non-daemon prints output immediately upon start, sleeps for 3 seconds, then prints again and returns.</p>
  
  <p>The problem is, the expected output from the daemon process doesn't show up at all.</p>
  
  <p>Reviewing past SO questions on daemons, the common issues appear to be either the other processes ending before the daemon, or the stdout requiring flushing to show output.  Both have (I <em>think</em>) been addressed, however I continue to only see printed output from non-daemonic processes.</p>
  
  <p><strong>The code:</strong></p>
  
  <pre><code>from multiprocessing import Process, current_process
  import sys
  import time
  
  def worker():
      """
      Announce that the process has started, sleep 3 seconds
      then announce that the process is ending.
      """
      name = current_process().name
      print name, 'starting...'
      sys.stdout.flush()
  
      time.sleep(3)
      print name, 'ending...'
      sys.stdout.flush()
  
      return
  
  
  def daemon():
      """
      Announce that the process has started, beep, then beep
      once every second
      """
      name = current_process().name
      print name, 'starting...'
      print 'beep...'
      sys.stdout.flush()
  
      while True:
          time.sleep(1)
          print 'beep...'
          sys.stdout.flush()
  
  
  if __name__=='__main__':
      d = Process(target=daemon)
      d.daemon = True
      d.start()
  
      p = Process(target=worker)
      p.daemon = False
      p.start()
  </code></pre>
  
  <p><strong>Expected Output:</strong></p>
  
  <pre><code>Process-1 starting... # Order here may vary
  beep...
  Process-2 starting...
  beep...
  beep...
  Process-2 ending... #There may or may not be another beep here
  </code></pre>
  
  <p><strong>What actually gets produced:</strong></p>
  
  <pre><code>Process-2 starting...
  Process-2 ending...
  </code></pre>
  
  <p>Any advice on why this is happening would be truly appreciated.</p>