ProProgrammer

Untitled

Sep 30th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import requests
  2.  
  3. """
  4. api_endpoint is the custom endpoint that returns your desired
  5. response based on whether or not Django Server is ready to take
  6. on requests
  7. """
  8. response = requests.get(api_endpoint)
  9.  
  10. while response.status_code != 200:
  11.     time.sleep(1) # Sleep for 1 second
  12.     response = requests.get(api_endpoint)
  13.  
  14. # Once this while loop breaks, this indicates we are good to proceed
  15.  
  16. if response.status_code == 200:
  17.     # Do rest of your job here
Add Comment
Please, Sign In to add comment