File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -706,19 +706,27 @@ def free_port(self):
706
706
if self .should_free_port :
707
707
release_port (self .port )
708
708
709
- def cleanup (self ):
709
+ def cleanup (self , max_attempts = 3 ):
710
710
"""
711
711
Stop node if needed and remove its data directory.
712
712
713
713
Returns:
714
714
This instance of PostgresNode.
715
715
"""
716
716
717
+ attempts = 0
718
+
717
719
# try stopping server
718
- try :
719
- self .stop ()
720
- except :
721
- pass
720
+ while attempts < max_attempts :
721
+ try :
722
+ self .stop ()
723
+ break # OK
724
+ except ExecUtilException as e :
725
+ pass # one more time
726
+ except Exception as e :
727
+ break # screw this
728
+
729
+ attempts += 1
722
730
723
731
# remove data directory
724
732
shutil .rmtree (self .data_dir , ignore_errors = True )
@@ -845,8 +853,8 @@ def poll_query_until(self,
845
853
raise_internal_error: mute InternalError?
846
854
"""
847
855
848
- attemps = 0
849
- while attemps < max_attempts :
856
+ attempts = 0
857
+ while attempts < max_attempts :
850
858
try :
851
859
res = self .execute (dbname = dbname ,
852
860
query = query ,
@@ -877,7 +885,7 @@ def poll_query_until(self,
877
885
raise e
878
886
879
887
time .sleep (sleep_time )
880
- attemps += 1
888
+ attempts += 1
881
889
882
890
raise TimeoutException ('Query timeout' )
883
891
You can’t perform that action at this time.
0 commit comments