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):
706706 if self .should_free_port :
707707 release_port (self .port )
708708
709- def cleanup (self ):
709+ def cleanup (self , max_attempts = 3 ):
710710 """
711711 Stop node if needed and remove its data directory.
712712
713713 Returns:
714714 This instance of PostgresNode.
715715 """
716716
717+ attempts = 0
718+
717719 # 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
722730
723731 # remove data directory
724732 shutil .rmtree (self .data_dir , ignore_errors = True )
@@ -845,8 +853,8 @@ def poll_query_until(self,
845853 raise_internal_error: mute InternalError?
846854 """
847855
848- attemps = 0
849- while attemps < max_attempts :
856+ attempts = 0
857+ while attempts < max_attempts :
850858 try :
851859 res = self .execute (dbname = dbname ,
852860 query = query ,
@@ -877,7 +885,7 @@ def poll_query_until(self,
877885 raise e
878886
879887 time .sleep (sleep_time )
880- attemps += 1
888+ attempts += 1
881889
882890 raise TimeoutException ('Query timeout' )
883891
You can’t perform that action at this time.
0 commit comments