Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

how to increase 10min http request using taskqueue.add() in google appengine Python

My http request is showing deadline error like your soft memory 120mb out of 12 requests . here i want to increase http request time 10min with taskqueue.add() method.thanks in advance.

class ExportHandler(BaseHandler):
    def get(self):
        tables = []
        app_models = [m for m in dir(models.app) if not m.startswith("__")]
        admin_models = [m for m in dir(models.admin) if not m.startswith("__")]
        total = app_models+admin_models
        for mname in total:
            if mname not in REMOVE:
                label = title(mname)
                tables.append({'value':mname, 'label':label})
        fromdate = None
        todate = None
        if "fromdate" in self.request.GET:
            fdate = self.request.GET['fromdate']
            try:
                fromdate = datetime.strptime(fdate, "%m/%d/%Y")
            except Exception as e:
                pass
        if "todate" in self.request.GET:
            tdate = self.request.GET['todate']
            try:
                todate = datetime.strptime(tdate, "%m/%d/%Y")
                todate = todate+timedelta(days=1)
            except Exception as e:
                pass
        if fromdate is not None and todate is not None:
            table = self.request.GET['table']
            model_class = get_class(table, app_models, admin_models)

            model_name = model_class.__name__
            columns = model_class.properties().keys()
            query = model_class.gql("where created_date >= :1 and created_date <= :2", fromdate, todate)
            if 'date_time' in columns:
                query = model_class.gql("where date_time >= :1 and date_time <= :2", fromdate, todate)
 records = [i for i in query.run()]
            if bool(records):
                fmt = "%m/%d/%Y"
                filename = "%s_%s_%s" %(model_name, fromdate.strftime(fmt), todate.strftime(fmt))
                csvfile = self.response


                writer = csv.writer(csvfile, delimiter=",")
                writer.writerow(records[0].json().keys())

                for rec in records:

                    writer.writerow(rec.json().values())

                self.response.content_disposition = 'attachment; filename=%s.csv' % filename
                return self.response
            else:
                self.session.add_flash("No records found", key='error')                                      
        self.render_response("/admin/exportcsv/index.html", tables=tables)  

    def post(self):
        print self.request.POST
        self.render_response("/admin/exportcsv/index.html")  
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...