title: Python module threading as daemon with logging
body: <p>I am trying to create a module <code>init</code> and a module <code>mydaemon</code> in Python 2.7 under Debian 7. </p>
  
  <p>The module <code>init</code> checks the requirements such as db connections etc. Then,  <code>mydaemon</code> runs in a thread and uses the database to do things and write a logfile.</p>
  
  <p>The problem when setting up the thread daemon is that the logging and function call fails. 
  But if the thread not daemon working fine...</p>
  
  <p>Where am I wrong or what will be a better approach?</p>
  
  <p><strong>init.py</strong></p>
  
  <pre><code>import mydaemon, threading
  
  print 'start'
  t = threading.Thread( target = mydaemon.start, args = () )
  t.daemon = True # error here
  t.start()
  </code></pre>
  
  <p><strong>mydaemon.py</strong></p>
  
  <pre><code>import logging
  
  def start():
     work()
     return
  
  def work():
     logging.basicConfig( filename = 'mylog.log', level = logging.DEBUG )
     logging.info('foo log')
     print 'foo console' 
     return
  </code></pre>