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
2
3
3
4
MASTER_KEY = 'masterKey'
4
5
BASE_URL = 'http://127.0.0.1:7700'
@@ -8,8 +9,19 @@ def clear_all_indexes(client):
8
9
for index in indexes :
9
10
client .get_index (index ['uid' ]).delete ()
10
11
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