kill_server_and_check_close_wait.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
4 import sys
5 import rospy
6 import subprocess
7 import unittest
8 import rostest
9 
10 class CloseWaitCheck(unittest.TestCase):
11  def __init__(self, *args):
12  super(CloseWaitCheck, self).__init__(*args)
13  rospy.init_node("ClosWaitCheck")
14  def setUp(self):
15  True
16 
17  # this works for hydro, but not for groovy https://github.com/ros/ros_comm/issues/325
18  @unittest.expectedFailure
20  rospy.loginfo("check close_wait...")
21  num = 0
22  for i in range(5):
23  num = int(subprocess.check_output("lsof -nl | grep rosmaster | grep CLOSE_WAIT | wc -l", shell=True))
24  rospy.loginfo("number of close_wait is ... %d (%d)"%(num, i))
25  self.assert_(num>1, "some socket is not closed, found CLOSE_WAIT")
26  subprocess.call("rosnode kill sample_topic_buffer_server", shell=True)
27  rospy.sleep(rospy.Duration(1.0))
28  return True
29 
30 
31 
32 if __name__ == '__main__':
33  try:
34  rostest.run('rostest', "CloseWaitCheck", CloseWaitCheck, sys.argv)
35  except KeyboardInterrupt, e:
36  pass
37  print "exiting"
38 
39 # while [ t ]; do
40 # NUM_OF_PROCESS=`lsof -nl | grep rosmaster | grep CLOSE_WAIT | wc -l`
41 # echo $NUM_OF_PROCESS
42 # if [ $NUM_OF_PROCESS != 0 ]; then
43 # exit -1
44 # fi
45 # sleep 5
46 # rosnode kill sample_topic_buffer_server
47 # done
48 
49 


jsk_topic_tools
Author(s): Kei Okada , Yusuke Furuta
autogenerated on Tue Feb 6 2018 03:45:19