My RequestHandler looks like this:
class GetChart(webapp2.RequestHandler):
def post(self):
station_id = cgi.escape(self.request.get('id'))
request_time = cgi.escape(self.request.get('time'))
request_date_string = cgi.escape(self.request.get('date'))
request_date = datetime.strptime(
request_date_string, "%m/%d/%Y")
# Build the URL string. (Details removed.)
url_string = ****
logging.info(url_string)
sock = urllib2.urlopen(url_string)
data = sock.read()
sock.close()
for line in data.split('\n'):
# If I put 'pass' here instead, there's no delay between
# the 'Returning' and the response actually being sent.
logging.info(line)
result_json = {'status': 'Not implemented'}
self.response.out.write(json.dumps(result_json))
logging.info('Returning.')
logging.basicConfig(level=logging.INFO)
app = webapp2.WSGIApplication([('/', MainPage),
('/submit', GetChart)],
debug=True)
In my logs, I see this:
INFO 2011-11-26 19:41:44,243 atmosview.py:131] Returning.
INFO 2011-11-26 19:41:51,331 dev_appserver.py:2753] "POST /submit HTTP/1.1" 200 -
That’s a 7 second delay between the ‘Returning’ being logged, and the response actually being sent. Why is this?
I also notice that if I replace the logging.info(line) with pass, the delay is much less: about 0.2 seconds.
Is there something with the logging module that causes the function to not actually return immediately, especially when a lot of calls have been made to logging.info()?
It looks like this may be a bug in the AppEngine 1.6.0 dev_appserver: code.google.com/p/googleappengine/issues/detail?id=6315