def test_clean_pid_files_on_keyboard_interrupt(self): path = os.path.join(FIXTURES_PATH, 'clean-pids-app') initcmd = CommandInit() opts = FakeOptions(app_path=path) initcmd.run(opts) open(os.path.join(path, 'pid/master/3340.pid'), 'w') open(os.path.join(path, 'pid/worker/2736.pid'), 'w') open(os.path.join(path, 'pid/worker/3847.pid'), 'w') with patch('os.wait'): with patch('os.getpid'): os.getpid.side_effect = lambda: 3340 os.wait.side_effect = KeyboardInterrupt() cli = Cli() cli.options = opts cli.log = Mock() cli.workers = [2736, 3847] cli._wait_workers() app = WsgidApp(path) self.assertEquals([], app.master_pids()) self.assertEquals([], app.worker_pids())
def test_clean_pid_files_on_keyboard_interrupt(self, *args): path = os.path.join(FIXTURES_PATH, 'clean-pids-app') initcmd = CommandInit() opts = FakeOptions(app_path=path) initcmd.run(opts) open(os.path.join(path, 'pid/master/3340.pid'), 'w') open(os.path.join(path, 'pid/worker/2736.pid'), 'w') open(os.path.join(path, 'pid/worker/3847.pid'), 'w') with patch('os.wait'): with patch('os.getpid'): os.getpid.side_effect = lambda: 3340 os.wait.side_effect = KeyboardInterrupt() cli = Cli() cli.options = opts cli.log = Mock() cli.workers = [2736, 3847] cli._wait_workers() app = WsgidApp(path) self.assertEquals([], app.master_pids()) self.assertEquals([], app.worker_pids())