summaryrefslogtreecommitdiff
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-07-22 11:27:10 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:32 +0000
commit384c5cc8ac5dfd8132887603fc7eb54f2321664b (patch)
tree953aa2d73067b1a1f60dc8def51b27748a5fa54a /bitbake/lib/bb
parent902b5da3f667f01d741cf702612698fc60a30f3b (diff)
downloadopenembedded-core-384c5cc8ac5dfd8132887603fc7eb54f2321664b.tar.gz
openembedded-core-384c5cc8ac5dfd8132887603fc7eb54f2321664b.tar.bz2
openembedded-core-384c5cc8ac5dfd8132887603fc7eb54f2321664b.tar.xz
openembedded-core-384c5cc8ac5dfd8132887603fc7eb54f2321664b.zip
Add the ability to use runqueue schedulers from the metadata
If you create a runqueue scheduler class in a python module, available in the usual python search path, you can now make it available to bitbake via the BB_SCHEDULERS variable, and the user can then select it as they select any other scheduler. Example usage: In a test.py I placed appropriately: import bb.runqueue class TestScheduler(bb.runqueue.RunQueueScheduler): name = "myscheduler" In local.conf, to make it available and select it: BB_SCHEDULERS = "test.TestScheduler" BB_SCHEDULER = "myscheduler" (Bitbake rev: 4dd38d5cfb80f9bb72bc41a629c3320b38f7314d) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/runqueue.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 6d9f6dc8d..a1f79e9f0 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -177,6 +177,25 @@ class RunQueueData:
self.stampwhitelist = bb.data.getVar("BB_STAMP_WHITELIST", cfgData, 1) or ""
self.multi_provider_whitelist = (bb.data.getVar("MULTI_PROVIDER_WHITELIST", cfgData, 1) or "").split()
+ self.schedulers = set(obj for obj in globals().itervalues()
+ if type(obj) is type and issubclass(obj, RunQueueScheduler))
+
+ user_schedulers = bb.data.getVar("BB_SCHEDULERS", cfgData, True)
+ if user_schedulers:
+ for sched in user_schedulers.split():
+ if not "." in sched:
+ bb.note("Ignoring scheduler '%s' from BB_SCHEDULERS: not an import" % sched)
+ continue
+
+ modname, name = sched.rsplit(".", 1)
+ try:
+ module = __import__(modname, fromlist=(name,))
+ except ImportError, exc:
+ logger.critical("Unable to import scheduler '%s' from '%s': %s" % (name, modname, exc))
+ raise SystemExit(1)
+ else:
+ self.schedulers.add(getattr(module, name))
+
self.reset()
def reset(self):
@@ -1183,17 +1202,14 @@ class RunQueueExecuteTasks(RunQueueExecute):
event.fire(bb.event.StampUpdate(self.rqdata.target_pairs, self.rqdata.dataCache.stamp), self.cfgData)
- schedulers = [obj for obj in globals().itervalues()
- if type(obj) is type and issubclass(obj, RunQueueScheduler)]
- for scheduler in schedulers:
+ for scheduler in self.rqdata.schedulers:
if self.scheduler == scheduler.name:
self.sched = scheduler(self, self.rqdata)
+ bb.msg.debug(1, bb.msg.domain.RunQueue, "Using runqueue scheduler '%s'" % scheduler.name)
break
else:
- bb.error("Invalid scheduler '%s', using default 'speed' scheduler" % self.scheduler)
- bb.error("Available schedulers: %s" % ", ".join(obj.name for obj in schedulers))
- self.sched = RunQueueSchedulerSpeed(self, self.rqdata)
-
+ bb.fatal("Invalid scheduler '%s'. Available schedulers: %s" %
+ (self.scheduler, ", ".join(obj.name for obj in self.rqdata.schedulers)))
def task_completeoutright(self, task):
"""