title: python web thread
body: <p>So I have a simple python cgi script. The web front end is used to add stuff to a database, and I have update() function that does some cleanup.</p>
  
  <p>I want to run the update() function every time something is added to site, but it needs to be in the background. That is, the webpage should finish loading without waiting for the update() function to finish.</p>
  
  <p>Now I use:</p>
  
  <pre><code>-add stuff to db
  Thread(target=update).start()
  -redirect to index page
  </code></pre>
  
  <p>The problem seems to be that python does not want to finish the request (redirect) until the update() thread is done. </p>
  
  <p>Any ideas?</p>