Код: Выделить всё
"ExceptionMessage : Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: TooManyRequests (429); Substatus: 3200; ActivityId: ab30cd85-000; Reason: (\r\nErrors : [\r\n "Request rate is large."
Примечание. p>
Ниже приведен пример кода, который я использовал для справки:
Код: Выделить всё
# Load data from Databricks
df = spark.sql("SELECT * FROM MyTable)")
# Transform data into vertices and edges
vertices = df.selectExpr("Client","Child","Parent","Relation","Name")
edges = df.selectExpr("Child","Parent","Relation")
# Function to handle exponential backoff
def exponential_backoff(retries):
delay = min(2 ** retries, 60) # Cap the delay at 60 seconds
time.sleep(delay)
# Write vertices to Cosmos DB
for row in vertices.collect():
retries = 0
while retries < 10: # Retry up to 10 times
try:
client.submit(f"g.addV('Party').property('Id', '{row.Child}').property('Name', '{row.Name}')
client.submit(f"g.addV('Party').property('Id', '{row.Parent}').property('Name', '{row.Name}')
break
except GremlinServerError as e:
if e.status_code == 429:
print(f"Rate limit exceeded. Retrying in {2 ** retries} seconds...")
exponential_backoff(retries)
retries += 1
else:
print(f"Error adding vertex: {e}")
break
# Write edges to Cosmos DB
for row in edges.collect():
retries = 0
while retries < 5: # Retry up to 5 times
try:
client.submit(f"g.V().has('Party', 'Id','{row.Child}').addE('knows').to(g.V().has('Party', 'Id','{row.Parent}')).property('Relation', '{row.Relation}')")
break
except GremlinServerError as e:
if e.status_code == 429:
print(f"Rate limit exceeded. Retrying in {2 ** retries} seconds...")
exponential_backoff(retries)
retries += 1
else:
print(f"Error adding edge: {e}")
break
Заранее спасибо,
С уважением
Подробнее здесь: https://stackoverflow.com/questions/791 ... rror-tooma
Мобильная версия