File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 1- import time
1+ from datetime import datetime
2+ from time import sleep
23
34MASTER_KEY = 'masterKey'
45BASE_URL = 'http://127.0.0.1:7700'
@@ -8,8 +9,19 @@ def clear_all_indexes(client):
89 for index in indexes :
910 client .get_index (index ['uid' ]).delete ()
1011
11- def wait_for_dump_creation (client , dump_uid ):
12- dump_status = client .get_dump_status (dump_uid )
13- while dump_status ['status' ] == 'in_progress' :
14- time .sleep (0.1 )
15- dump_status = client .get_dump_status (dump_uid )
12+ """
13+ Waits until the end of the dump creation.
14+
15+ Raises a TimeoutError if the `timeout_in_ms` is reached.
16+ """
17+ def wait_for_dump_creation (client , dump_uid , timeout_in_ms = 10000 , interval_in_ms = 500 ):
18+ start_time = datetime .now ()
19+ elapsed_time = 0
20+ while elapsed_time < timeout_in_ms :
21+ dump = client .get_dump_status (dump_uid )
22+ if dump ['status' ] != 'in_progress' :
23+ return
24+ sleep (interval_in_ms / 1000 )
25+ time_delta = datetime .now () - start_time
26+ elapsed_time = time_delta .seconds * 1000 + time_delta .microseconds / 1000
27+ raise TimeoutError
You can’t perform that action at this time.
0 commit comments