summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-03-20 17:46:01 +0000
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-03-24 21:24:24 +0900
commite0ca1ce9980e2b779f3852add4a241657689f738 (patch)
tree6595b4d63ee36d4b9b85652c9f8e07ca04ce6f41
parent9e85e36e4be36617a9e4e8298c7a6dff1766b3f0 (diff)
downloadbuildstream-e0ca1ce9980e2b779f3852add4a241657689f738.tar.gz
plugin.py: make _unique_id accessible to the core
_unique_id is set at instantiation and never modified afterwards. Since the guildelines for the project is to never modify directly an object's state, accessing _unique_id as an attribute is safe. Moreover this will save us some cost of calling functions.
-rw-r--r--buildstream/_frontend/app.py2
-rw-r--r--buildstream/_scheduler/jobs/elementjob.py4
-rw-r--r--buildstream/_scheduler/queues/queue.py2
-rw-r--r--buildstream/element.py2
-rw-r--r--buildstream/plugin.py15
5 files changed, 9 insertions, 16 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index f89202154..53a342899 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -531,7 +531,7 @@ class App():
queue = job.queue
# Get the last failure message for additional context
- failure = self._fail_messages.get(element._get_unique_id())
+ failure = self._fail_messages.get(element._unique_id)
# XXX This is dangerous, sometimes we get the job completed *before*
# the failure message reaches us ??
diff --git a/buildstream/_scheduler/jobs/elementjob.py b/buildstream/_scheduler/jobs/elementjob.py
index 8ce5c062f..4d53a9d3d 100644
--- a/buildstream/_scheduler/jobs/elementjob.py
+++ b/buildstream/_scheduler/jobs/elementjob.py
@@ -73,7 +73,7 @@ class ElementJob(Job):
self._complete_cb = complete_cb # The complete callable function
# Set the task wide ID for logging purposes
- self.set_task_id(element._get_unique_id())
+ self.set_task_id(element._unique_id)
@property
def element(self):
@@ -100,7 +100,7 @@ class ElementJob(Job):
args = dict(kwargs)
args['scheduler'] = True
self._scheduler.context.message(
- Message(self._element._get_unique_id(),
+ Message(self._element._unique_id,
message_type,
message,
**args))
diff --git a/buildstream/_scheduler/queues/queue.py b/buildstream/_scheduler/queues/queue.py
index af4698350..ec1f1405b 100644
--- a/buildstream/_scheduler/queues/queue.py
+++ b/buildstream/_scheduler/queues/queue.py
@@ -348,7 +348,7 @@ class Queue():
# a message for the element they are processing
def _message(self, element, message_type, brief, **kwargs):
context = element._get_context()
- message = Message(element._get_unique_id(), message_type, brief, **kwargs)
+ message = Message(element._unique_id, message_type, brief, **kwargs)
context.message(message)
def _element_log_path(self, element):
diff --git a/buildstream/element.py b/buildstream/element.py
index bc939bc92..dd1169f15 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1262,7 +1262,7 @@ class Element(Plugin):
for source in self.__sources:
old_ref = source.get_ref()
new_ref = source._track()
- refs.append((source._get_unique_id(), new_ref))
+ refs.append((source._unique_id, new_ref))
# Complimentary warning that the new ref will be unused.
if old_ref != new_ref and self._get_workspace():
diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index 001de2355..f6a10384d 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -178,10 +178,10 @@ class Plugin():
# Unique ID
#
# This id allows to uniquely identify a plugin.
- self.__unique_id = next(self.__id_generator)
+ self._unique_id = next(self.__id_generator)
# register ourself in the table containing all existing plugins
- self.__TABLE[self.__unique_id] = self
+ self.__TABLE[self._unique_id] = self
self.__context = context # The Context object
self.__project = project # The Project object
@@ -544,7 +544,7 @@ class Plugin():
self.call(... command which takes time ...)
"""
with self.__context.timed_activity(activity_name,
- unique_id=self.__unique_id,
+ unique_id=self._unique_id,
detail=detail,
silent_nested=silent_nested):
yield
@@ -667,13 +667,6 @@ class Plugin():
def _get_project(self):
return self.__project
- # _get_unique_id():
- #
- # Fetch the plugin's unique identifier
- #
- def _get_unique_id(self):
- return self.__unique_id
-
# _get_provenance():
#
# Fetch bst file, line and column of the entity
@@ -758,7 +751,7 @@ class Plugin():
return (exit_code, output)
def __message(self, message_type, brief, **kwargs):
- message = Message(self.__unique_id, message_type, brief, **kwargs)
+ message = Message(self._unique_id, message_type, brief, **kwargs)
self.__context.message(message)
def __note_command(self, output, *popenargs, **kwargs):