def METHOD_NAME(params, block=True, autocommit=True):
  if params.db.password is None:
    password = ""
  else:
    password = params.db.password
  retry_count = 0
  retry_max = 20
  sleep_time = 0.1
  while retry_count < retry_max:
    try:
      dbobj=MySQLdb.connect(
          passwd=password,
          user=params.db.user,
          host=params.db.host,
          db=params.db.name,
          port=params.db.port,
          autocommit=autocommit
      )
      return dbobj
    except Exception as e:
      retry_count += 1
      if not block: raise e
      if "Too many connections" in str(e):
        print("Too many connections, retry", retry_count)
      elif  "Can't connect to MySQL server" in str(e):
        print("Couldn't connect to MYSQL, retry", retry_count)
      elif "Can't create a new thread" in str(e):
        print("MySQL can't create a new thread. Retry", retry_count)
      else:
        raise e
      import time
      time.sleep(sleep_time)
      sleep_time *= 2
  raise Sorry("Couldn't execute connect to MySQL. Too many reconnects.")