I am working on a simple google AppEngine app that uses python threads. The POST method for MainHandler is where the problem is. The Post method here is supposed to start a thread (which does background downloading) as the last thing before it returns (sending the HTML response). The problem is that although the threads starts just fine, program control doesn't move beyond the start() statement - and so doesn't leave the POST method until the thread is actually finished. It is as though the join() method was called on this thread. I have also tried using a Timer in case the thread was simply hogging cpu time so that control couldn't get to the 'return' fast enough. But that wasn't it either.
The threading code was working fine before I converted it to a Google App. Threads would start and control would move on to the next commands every time. Is there something specific about server-side google apps, or is there some workaround with more advanced threading?...
# from class MainHandler(webapp.RequestHandler):
logging.info( "ENTERED 'POST' METHOD" )
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write( "<p>-- PROCESSING --</p>" )
logging.info( "LEAVING 'POST' METHOD" )
#Timer(3.0, myPersonDownloader.start ).start()
return # Doesn't get here until thread is finished.
application = webapp.WSGIApplication(
[('/.*', MainHandler)], debug=True)
if __name__ == '__main__':