Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5af8987

Browse files
committed
add max_attempts to cleanup()
1 parent0fc86c9 commit5af8987

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎testgres/testgres.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -706,19 +706,27 @@ def free_port(self):
706706
ifself.should_free_port:
707707
release_port(self.port)
708708

709-
defcleanup(self):
709+
defcleanup(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+
whileattempts<max_attempts:
721+
try:
722+
self.stop()
723+
break# OK
724+
exceptExecUtilExceptionase:
725+
pass# one more time
726+
exceptExceptionase:
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-
whileattemps<max_attempts:
856+
attempts=0
857+
whileattempts<max_attempts:
850858
try:
851859
res=self.execute(dbname=dbname,
852860
query=query,
@@ -877,7 +885,7 @@ def poll_query_until(self,
877885
raisee
878886

879887
time.sleep(sleep_time)
880-
attemps+=1
888+
attempts+=1
881889

882890
raiseTimeoutException('Query timeout')
883891

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp