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

Side by Side Diff: scripts/slave/xvfb.py

Issue 2153083002: xvfb: improve robustness when stale lock files exist (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: fix Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Functions to setup xvfb, which is used by the linux machines. 5 """Functions to setup xvfb, which is used by the linux machines.
6 """ 6 """
7 7
8 import os 8 import os
9 import platform 9 import platform
10 import signal 10 import signal
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 checkstarttime = time.time() 53 checkstarttime = time.time()
54 xdisplayproc = subprocess.Popen([xdisplaycheck_path, '--noserver'], 54 xdisplayproc = subprocess.Popen([xdisplaycheck_path, '--noserver'],
55 stdout=subprocess.PIPE, 55 stdout=subprocess.PIPE,
56 stderr=subprocess.STDOUT) 56 stderr=subprocess.STDOUT)
57 # Wait for xdisplaycheck to exit. 57 # Wait for xdisplaycheck to exit.
58 logs = xdisplayproc.communicate()[0] 58 logs = xdisplayproc.communicate()[0]
59 if xdisplayproc.returncode == 0: 59 if xdisplayproc.returncode == 0:
60 print 'xdisplaycheck says there is a display still running, exiting...' 60 print 'xdisplaycheck says there is a display still running, exiting...'
61 raise Exception('Display already present.') 61 raise Exception('Display already present.')
62 62
63 xvfb_lock_filename = '/tmp/.X%s-lock' % _XvfbDisplayIndex(slave_build_name)
64 if os.path.exists(xvfb_lock_filename):
65 print 'Removing stale xvfb lock file %r' % xvfb_lock_filename
66 try:
67 os.unlink(xvfb_lock_filename)
68 except OSError as e:
69 print 'Removing xvfb lock file failed: %s' % e
70
63 # Figure out which X server to try. 71 # Figure out which X server to try.
64 cmd = 'Xvfb' 72 cmd = 'Xvfb'
65 if server_dir and os.path.exists(server_dir): 73 if server_dir and os.path.exists(server_dir):
66 cmd = os.path.join(server_dir, 'Xvfb.' + platform.architecture()[0]) 74 cmd = os.path.join(server_dir, 'Xvfb.' + platform.architecture()[0])
67 if not os.path.exists(cmd): 75 if not os.path.exists(cmd):
68 cmd = os.path.join(server_dir, 'Xvfb') 76 cmd = os.path.join(server_dir, 'Xvfb')
69 if not os.path.exists(cmd): 77 if not os.path.exists(cmd):
70 print 'No Xvfb found in designated server path:', server_dir 78 print 'No Xvfb found in designated server path:', server_dir
71 raise Exception('No virtual server') 79 raise Exception('No virtual server')
72 80
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if os.path.exists(xvfb_pid_filename): 137 if os.path.exists(xvfb_pid_filename):
130 xvfb_pid = int(open(xvfb_pid_filename).read()) 138 xvfb_pid = int(open(xvfb_pid_filename).read())
131 print 'Stopping Xvfb with pid %d ...' % xvfb_pid 139 print 'Stopping Xvfb with pid %d ...' % xvfb_pid
132 # If the process doesn't exist, we raise an exception that we can ignore. 140 # If the process doesn't exist, we raise an exception that we can ignore.
133 try: 141 try:
134 os.kill(xvfb_pid, signal.SIGKILL) 142 os.kill(xvfb_pid, signal.SIGKILL)
135 except OSError: 143 except OSError:
136 print '... killing failed, presuming unnecessary.' 144 print '... killing failed, presuming unnecessary.'
137 os.remove(xvfb_pid_filename) 145 os.remove(xvfb_pid_filename)
138 print 'Xvfb pid file removed' 146 print 'Xvfb pid file removed'
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698