Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: tools/browser_tester/browsertester/browserprocess.py

Issue 7834028: Pulling back revision 6635 and 6634 due to broken builds. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/browser_tester/browsertester/browserlauncher.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/browser_tester/browsertester/browserprocess.py
===================================================================
--- tools/browser_tester/browsertester/browserprocess.py (revision 6635)
+++ tools/browser_tester/browsertester/browserprocess.py (working copy)
@@ -1,85 +0,0 @@
-#!/usr/bin/python
-# Copyright (c) 2011 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import signal
-import subprocess
-import time
-
-# mozrunner is needed as long as we are supporting versions of Python
-# before 2.6.
-import mozrunner
-
-class BrowserProcessBase(object):
-
- def __init__(self, handle):
- self.handle = handle
- print 'PID', self.handle.pid
-
- def GetReturnCode(self):
- return self.handle.returncode
-
- def IsRunning(self):
- return self.handle.poll() is None
-
- def Wait(self, wait_steps, sleep_time):
- self.term()
- i = 0
- # subprocess.wait() doesn't have a timeout, unfortunately.
- while self.IsRunning() and i < wait_steps:
- time.sleep(sleep_time)
- i += 1
-
- def Kill(self):
- if self.IsRunning():
- print 'KILLING the browser'
- try:
- self.kill()
- # If it doesn't die, we hang. Oh well.
- self.handle.wait()
- except Exception:
- # If it is already dead, then it's ok.
- # This may happen if the browser dies after the first poll, but
- # before the kill.
- if self.IsRunning():
- raise
-
-class BrowserProcess(BrowserProcessBase):
-
- def term(self):
- self.handle.terminate()
-
- def kill(self):
- self.handle.kill()
-
-
-class BrowserProcessPosix(BrowserProcessBase):
- """ This variant of BrowserProcess uses process groups to manage browser
- life time. """
-
- def term(self):
- os.killpg(self.handle.pid, signal.SIGTERM)
-
- def kill(self):
- os.killpg(self.handle.pid, signal.SIGKILL)
-
-
-def RunCommandWithSubprocess(cmd, env=None):
- handle = subprocess.Popen(cmd, env=env)
- return BrowserProcess(handle)
-
-
-def RunCommandWithMozrunner(cmd, env=None):
- handle = mozrunner.run_command(cmd, env=env)
- return BrowserProcess(handle)
-
-
-def RunCommandInProcessGroup(cmd, env=None):
- def SetPGrp():
- os.setpgrp()
- print 'I\'M THE SESSION LEADER!'
- handle = subprocess.Popen(cmd, env=env, preexec_fn=SetPGrp)
- return BrowserProcessPosix(handle)
-
« no previous file with comments | « tools/browser_tester/browsertester/browserlauncher.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698