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

Commit78603f8

Browse files
authored
Fix node.py: try_shutdown and cleanup (#144)
1 parent98b0286 commit78603f8

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

‎testgres/node.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -334,37 +334,38 @@ def _try_shutdown(self, max_attempts, with_force=False):
334334
attempts=0
335335
node_pid=self.pid
336336

337-
# try stopping server N times
338-
whileattempts<max_attempts:
339-
try:
340-
self.stop()
341-
break# OK
342-
exceptExecUtilException:
343-
pass# one more time
344-
exceptException:
345-
eprint('cannot stop node {}'.format(self.name))
346-
break
347-
348-
attempts+=1
349-
350-
# If force stopping is enabled and PID is valid
351-
ifwith_forceandnode_pid!=0:
352-
# If we couldn't stop the node
353-
p_status_output=self.os_ops.exec_command(cmd=f'ps -p{node_pid}',shell=True).decode('utf-8')
354-
ifself.status()!=NodeStatus.Stoppedandp_status_outputandstr(node_pid)inp_status_output:
337+
ifnode_pid>0:
338+
# try stopping server N times
339+
whileattempts<max_attempts:
355340
try:
356-
eprint(f'Force stopping node{self.name} with PID{node_pid}')
357-
self.os_ops.kill(node_pid,signal.SIGKILL,expect_error=False)
341+
self.stop()
342+
break# OK
343+
exceptExecUtilException:
344+
pass# one more time
358345
exceptException:
359-
# The node has already stopped
360-
pass
361-
362-
# Check that node stopped - print only column pid without headers
363-
p_status_output=self.os_ops.exec_command(f'ps -o pid= -p{node_pid}',shell=True,ignore_errors=True).decode('utf-8')
364-
ifp_status_outputandstr(node_pid)inp_status_output:
365-
eprint(f'Failed to stop node{self.name}.')
366-
else:
367-
eprint(f'Node{self.name} has been stopped successfully.')
346+
eprint('cannot stop node {}'.format(self.name))
347+
break
348+
349+
attempts+=1
350+
351+
# If force stopping is enabled and PID is valid
352+
ifwith_forceandnode_pid!=0:
353+
# If we couldn't stop the node
354+
p_status_output=self.os_ops.exec_command(cmd=f'ps -p{node_pid}',shell=True).decode('utf-8')
355+
ifself.status()!=NodeStatus.Stoppedandp_status_outputandstr(node_pid)inp_status_output:
356+
try:
357+
eprint(f'Force stopping node{self.name} with PID{node_pid}')
358+
self.os_ops.kill(node_pid,signal.SIGKILL,expect_error=False)
359+
exceptException:
360+
# The node has already stopped
361+
pass
362+
363+
# Check that node stopped - print only column pid without headers
364+
p_status_output=self.os_ops.exec_command(f'ps -o pid= -p{node_pid}',shell=True,ignore_errors=True).decode('utf-8')
365+
ifp_status_outputandstr(node_pid)inp_status_output:
366+
eprint(f'Failed to stop node{self.name}.')
367+
else:
368+
eprint(f'Node{self.name} has been stopped successfully.')
368369

369370
def_assign_master(self,master):
370371
"""NOTE: this is a private method!"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp