Commit a91d26de authored by maruel@chromium.org's avatar maruel@chromium.org

Force requirements modification to be locked.

... On my quest to make that stuff thread safe.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8135008

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@104033 0039d316-1c4b-4281-b951-d872f2087c98
parent 1333cb3e
...@@ -264,7 +264,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -264,7 +264,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
# self.parent is implicitly a requirement. This will be recursive by # self.parent is implicitly a requirement. This will be recursive by
# definition. # definition.
if self.parent and self.parent.name: if self.parent and self.parent.name:
self._requirements.add(self.parent.name) self.add_requirement(self.parent.name)
# For a tree with at least 2 levels*, the leaf node needs to depend # For a tree with at least 2 levels*, the leaf node needs to depend
# on the level higher up in an orderly way. # on the level higher up in an orderly way.
...@@ -283,10 +283,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -283,10 +283,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if i is self.parent: if i is self.parent:
break break
if i.name: if i.name:
self._requirements.add(i.name) self.add_requirement(i.name)
if isinstance(self.url, self.FromImpl): if isinstance(self.url, self.FromImpl):
self._requirements.add(self.url.module_name) self.add_requirement(self.url.module_name)
if self.name and self.should_process: if self.name and self.should_process:
for obj in self.root.depth_first_tree(): for obj in self.root.depth_first_tree():
...@@ -294,16 +294,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -294,16 +294,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
continue continue
# Step 1: Find any requirements self may need. # Step 1: Find any requirements self may need.
if self.name.startswith(posixpath.join(obj.name, '')): if self.name.startswith(posixpath.join(obj.name, '')):
self._requirements.add(obj.name) self.add_requirement(obj.name)
# Step 2: Find any requirements self may impose. # Step 2: Find any requirements self may impose.
if obj.name.startswith(posixpath.join(self.name, '')): if obj.name.startswith(posixpath.join(self.name, '')):
try: obj.add_requirement(self.name)
# Access to a protected member _requirements of a client class
# pylint: disable=W0212
obj.lock.acquire()
obj._requirements.add(self.name)
finally:
obj.lock.release()
if not self.name and self.parent: if not self.name and self.parent:
raise gclient_utils.Error('Dependency without name') raise gclient_utils.Error('Dependency without name')
......
...@@ -497,6 +497,10 @@ class WorkItem(object): ...@@ -497,6 +497,10 @@ class WorkItem(object):
def requirements(self): def requirements(self):
return tuple(self._requirements) return tuple(self._requirements)
@lockedmethod
def add_requirement(self, new):
self._requirements.add(new)
class ExecutionQueue(object): class ExecutionQueue(object):
"""Runs a set of WorkItem that have interdependencies and were WorkItem are """Runs a set of WorkItem that have interdependencies and were WorkItem are
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment