How to handle rate limit failure in assistant submit_tool_outputs_and_poll

Hi all,

When submitting tool outputs in assistant with self.client.beta.threads.runs.submit_tool_outputs_and_poll I sometimes run into my rate limit: “Rate limit reached …Please try again in …”

This is correctly returned by the API:
run.status == “failed”
run.last_error.code == “rate_limit_exceeded”

I then wait a bit and would like to redo the self.client.beta.threads.runs.submit_tool_outputs call. But then I get the answer: “Runs in status “failed” do not accept tool outputs.”

How do I properly handle the rate limit error in tool output submission?