[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

Thread starts, but control never moves past start() call.

Greetings all,
   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):

def post(self):
	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.
def main():
	application = webapp.WSGIApplication(
		[('/.*', MainHandler)], debug=True)

if __name__ == '__main__':

Open in new window

1 Solution
tau161Author Commented:
I found the unfortunate answer that I was looking for here.  Google App Engine does not support threading.  I wrote a fully working set of threaded base code which is now useless.  I have rewritten it from the ground up using Tasks, TaskQueues, and the Datastore, but it's just not the same. It feels like a hack job.  

Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now