mirror of
https://git.yoctoproject.org/poky
synced 2026-04-11 08:02:21 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
902b5da3f6
commit
384c5cc8ac
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user