コード例 #1
0
 def test_proc_alive(self):
     p = subprocess.Popen([self.executable])
     self.assertTrue(process.proc_alive(p))
     p.terminate()
     p.wait()
     self.assertFalse(process.proc_alive(p))
     self.assertFalse(process.proc_alive(None))
コード例 #2
0
 def test_proc_alive(self):
     p = subprocess.Popen([self.executable])
     self.assertTrue(process.proc_alive(p))
     p.terminate()
     p.wait()
     self.assertFalse(process.proc_alive(p))
     self.assertFalse(process.proc_alive(None))
コード例 #3
0
 def shutdown(self):
     """Send shutdown command and wait for the process to exit."""
     # Return early if this server has already exited.
     if not process.proc_alive(self.proc):
         return
     logger.info("Attempting to connect to %s", self.hostname)
     client = self.connection
     # Attempt the shutdown command twice, the first attempt might fail due
     # to an election.
     attempts = 2
     for i in range(attempts):
         logger.info("Attempting to send shutdown command to %s",
                     self.hostname)
         try:
             client.admin.command("shutdown", force=True)
         except ConnectionFailure:
             # A shutdown succeeds by closing the connection but a
             # connection error does not necessarily mean that the shutdown
             # has succeeded.
             pass
         # Wait for the server to exit otherwise rerun the shutdown command.
         try:
             return process.wait_mprocess(self.proc, 5)
         except TimeoutError as exc:
             logger.info("Timed out waiting on process: %s", exc)
             continue
     raise ServersError("Server %s failed to shutdown after %s attempts" %
                        (self.hostname, attempts))
コード例 #4
0
ファイル: servers.py プロジェクト: 10gen/mongo-orchestration
 def shutdown(self):
     """Send shutdown command and wait for the process to exit."""
     # Return early if this server has already exited.
     if not process.proc_alive(self.proc):
         return
     logger.info("Attempting to connect to %s", self.hostname)
     client = self.connection
     # Attempt the shutdown command twice, the first attempt might fail due
     # to an election.
     attempts = 2
     for i in range(attempts):
         logger.info("Attempting to send shutdown command to %s",
                     self.hostname)
         try:
             client.admin.command("shutdown", force=True)
         except ConnectionFailure:
             # A shutdown succeeds by closing the connection but a
             # connection error does not necessarily mean that the shutdown
             # has succeeded.
             pass
         # Wait for the server to exit otherwise rerun the shutdown command.
         try:
             return process.wait_mprocess(self.proc, 5)
         except TimeoutError as exc:
             logger.info("Timed out waiting on process: %s", exc)
             continue
     raise ServersError("Server %s failed to shutdown after %s attempts" %
                        (self.hostname, attempts))
コード例 #5
0
 def is_alive(self):
     return process.proc_alive(self.proc)
コード例 #6
0
 def is_alive(self):
     return process.proc_alive(self.proc)
コード例 #7
0
 def test_kill_mprocess(self):
     p = subprocess.Popen([self.executable])
     self.assertTrue(process.proc_alive(p))
     process.kill_mprocess(p)
     self.assertFalse(process.proc_alive(p))
コード例 #8
0
 def test_kill_mprocess(self):
     p = subprocess.Popen([self.executable])
     self.assertTrue(process.proc_alive(p))
     process.kill_mprocess(p)
     self.assertFalse(process.proc_alive(p))