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

Unified Diff: build/extract_from_cab.py

Issue 8921029: extract_from_cab script now takes a global lock while extracting from the CAB file. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/extract_from_cab.py
===================================================================
--- build/extract_from_cab.py (revision 114042)
+++ build/extract_from_cab.py (working copy)
@@ -8,8 +8,24 @@
import os
import subprocess
import sys
+import tempfile
+lock_file = os.path.join(tempfile.gettempdir(), 'expand.lock')
+def acquire_lock():
+ while True:
+ try:
+ fd = os.open(lock_file, os.O_CREAT | os.O_EXCL | os.O_RDWR)
+ return fd
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+ time.sleep(1000)
M-A Ruel 2011/12/13 01:34:23 time.sleep(10)
+
+def release_lock(fd):
+ os.close(fd)
+ os.unlink(lock_file)
+
M-A Ruel 2011/12/13 01:34:23 please keep 2 vertical lines between file level sy
def main():
if len(sys.argv) != 4:
print 'Usage: extract_from_cab.py cab_path archived_file output_dir'
@@ -17,17 +33,21 @@
[cab_path, archived_file, output_dir] = sys.argv[1:]
- # Invoke the Windows expand utility to extract the file.
- level = subprocess.call(
- ['expand', cab_path, '-F:' + archived_file, output_dir])
- if level != 0:
- print 'Cab extraction(%s, %s, %s) failed.' % (
- cab_path, archived_file, output_dir)
- print 'Trying a second time.'
+ lock_fd = acquire_lock()
+ try:
+ # Invoke the Windows expand utility to extract the file.
level = subprocess.call(
['expand', cab_path, '-F:' + archived_file, output_dir])
if level != 0:
- return level
+ print 'Cab extraction(%s, %s, %s) failed.' % (
+ cab_path, archived_file, output_dir)
+ print 'Trying a second time.'
M-A Ruel 2011/12/13 01:34:23 Remove the retry with the locking you add?
+ level = subprocess.call(
+ ['expand', cab_path, '-F:' + archived_file, output_dir])
+ if level != 0:
+ return level
+ finally:
+ release_lock(lock_fd)
# The expand utility preserves the modification date and time of the archived
# file. Touch the extracted file. This helps build systems that compare the
« 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