title: Submitting 2 https requests in 2 minute interval using Python
body: <p>Following is my python code, where am trying to run 2 https requests, first one to start my databrick cluster.  Since the cluster startup takes around 2 minutes, I am trying to have time.sleep for 2 minutes and then submit my second https to run a databricks job.  These are runing from my AWS Lambda.  I have tried with AWS Step function as well, but am getting different errors and hence decided to go with lambda.</p>
  
  <pre><code>from __future__ import print_function
  import json
  import boto3
  import time
  import urllib
  import re
  import pymysql
  import sys
  import requests
  import base64
  import time
  
  s3 = boto3.client('s3')
  domain = 'mydatabricks.cloud.databricks.com'
  tokenStr = 'token:tokenstr'
  
  
  def lambda_handler(event, context):
  
      response = requests.post('https://%s/api/2.0/clusters/start' % (domain),
      headers = {"Authorization": "Basic " + base64.standard_b64encode(tokenStr)},
      json = {"cluster_id": "ddddd-sss23-2232323"})
      seconds = 200
      time.sleep(seconds)
      if response.status_code == 200:
          print("slept for seconds : ", str(seconds))
          print("Cluster started / completed successfully ***************")
      else:
          print ("Error in starting cluster !!!!!!!!!!!!!! %s: %s" % (response.json()["error_code"], response.json()["message"]))
  
      #time.sleep(180)
      while True:
          try:
              response2 = requests.post('https://%s/api/2.0/jobs/run-now' % (domain),
              headers = {"Authorization": "Basic " + base64.standard_b64encode(tokenStr)},
              json = {"job_id": 12345})
          except Exception as e:
              print(e)
              time.sleep(180)
  
      #   if response2.status_code == "INVALID_STATE":
      #    print("Job started / completed successfully ***************")
      #else:
      #    print ("Error in running the job 28885 !!!!!!!!!!!!!! %s: %s" % (response2.json()["error_code"], response2.json()["message"]))
  </code></pre>
  
  <p>The error message am getting with the above is :</p>
  
  <pre><code>2018-08-21T13:47:26.542Z baa565b5-a548-11e8-9585-8d99dc1af95e Task timed out after 3.00 seconds
  </code></pre>
  
  <p>Please help how to submit 2 https requests with an interval/status of first request.  Thanks</p>