How to solve "The process was completed because the request submission deadline was exceeded. (Error code 123)" in the google api?

I have projects deployed in the Google App Engine with the Google API (Python). Each request to any of the API creates a connection to the database, executes the procedure and returns data and closes the connection. I could not access any of the APIs as it was showing

β€œThe process was completed because the request deadline was exceeded. (Error code 123)” and β€œThis request started a new process for your application and thus caused your application code to load for the first time. It may take more time and use more CPU than a typical request for your application. " error.

The database is also in the cloud (Google Cloud SQL). When I checked, there were 900 connections and more than 150 instances were executed, but the api request was not processed. This happens frequently. So I restart the database server again and deploy the API code again to solve this problem. What is the problem and how can I solve this problem forever? Here is my python code to connect to the database: -

import logging
import traceback
import os
import MySQLdb
from warnings import filterwarnings

filterwarnings('ignore', category = MySQLdb.Warning)

class TalkWithDB:
    def callQueries(self,query,req_args):
        try:
            if (os.getenv('SERVER_SOFTWARE') and os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')):
                db = MySQLdb.connect(unix_socket = UNIX_SOCKET + INSTANCE_NAME, host = HOST, db = DB, user = USER ,charset='utf8',use_unicode=True)
            else:
                db = MySQLdb.connect(host = HOST, port = PORT, db = DB, user = USER, passwd = PASSWORD,charset='utf8',use_unicode=True)

            cursor = db.cursor()
            cursor.connection.autocommit(True)
        try:
        sql = query+str(req_args)
        logging.info("QUERY = "+ sql )
        cursor.execute(sql)     
        procedureResult = cursor.fetchall();
        if str(procedureResult) == '()':
            logging.info("Procedure Returned 0 Record")
            procedureResult = []
            procedureResult.append({0:"NoRecord", 1:"Error"})
            #procedureResult = (("NoRecord","Error",),)
        elif procedureResult[0][0] == 'Session Expired'.encode(encoding='unicode-escape',errors='strict'):
            procedureResult = []
            procedureResult.append({0:"SessionExpired", 1:"Error"})                     
            except Exception, err:
        logging.info("ConnectDB.py : - Error in Procedure Calling :  " + traceback.format_exc())
        #procedureResult = (('ProcedureCallError','Error',),)
        procedureResult = []

        procedureResult.append({0:"ProcedureCallError", 1:"Error"})         

        except Exception, err:
            logging.info("Error In DataBase Connection : " + traceback.format_exc())
           #procedureResult = (('DataBaseConnectionError','Error',),)
        procedureResult = []

        procedureResult.append({0:"DataBaseConnectionError", 1:"Error"})       
# disconnect from server
        finally:
            try:
                cursor.close()
                db.close()
            except Exception, err:
                logging.info("Error In Closing Connection : " + traceback.format_exc())
            return procedureResult
+4
source share
1 answer

Two possible improvements:

  • , , , , , , . , , , .
  • (, Google) . 10- , 60- .
+3

All Articles