import time from gradio_client import Client ready = False while not ready: try: c = Client('https://arun-misra-my-env.hf.space') c.predict(api_name='/reset_env') ready = True print('READY') except Exception: time.sleep(5)