summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-03-20 17:46:01 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-21 12:52:55 +0000
commit90af89909960fd97e480bc684ab392f4147e2591 (patch)
tree1a23e2a71468c93a0b2a97f859779b557d9770a8
parentbd7e75f99c28fbebedfe8d5db98a922b0e140a62 (diff)
downloadbuildstream-90af89909960fd97e480bc684ab392f4147e2591.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
-rw-r--r--buildstream/sandbox/sandbox.py2
6 files changed, 10 insertions, 17 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index 67fcc8370..a659b202a 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 fa0d34fb3..fb5d38e11 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 9f0563fa5..1efcffc16 100644
--- a/buildstream/_scheduler/queues/queue.py
+++ b/buildstream/_scheduler/queues/queue.py
@@ -316,7 +316,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 35f656fca..3a3eaa236 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1390,7 +1390,7 @@ class Element(Plugin):
for index, source in enumerate(self.__sources):
old_ref = source.get_ref()
new_ref = source._track(self.__sources[0:index])
- 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 bbea045b6..a1fb74289 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -216,10 +216,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
@@ -602,7 +602,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
@@ -725,13 +725,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
@@ -816,7 +809,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):
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py
index f11ddea1d..93db2f8ca 100644
--- a/buildstream/sandbox/sandbox.py
+++ b/buildstream/sandbox/sandbox.py
@@ -122,7 +122,7 @@ class Sandbox():
# Plugin ID for logging
plugin = kwargs.get('plugin', None)
if plugin:
- self.__plugin_id = plugin._get_unique_id()
+ self.__plugin_id = plugin._unique_id
else:
self.__plugin_id = None