summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/runqueue.py
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/runqueue.py
parent902b5da3f667f01d741cf702612698fc60a30f3b (diff)
downloadpoky-384c5cc8ac5dfd8132887603fc7eb54f2321664b.tar.gz
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/runqueue.py')
-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 6d9f6dc8d4..a1f79e9f03 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -177,6 +177,25 @@ class RunQueueData:
177 self.stampwhitelist = bb.data.getVar("BB_STAMP_WHITELIST", cfgData, 1) or "" 177 self.stampwhitelist = bb.data.getVar("BB_STAMP_WHITELIST", cfgData, 1) or ""
178 self.multi_provider_whitelist = (bb.data.getVar("MULTI_PROVIDER_WHITELIST", cfgData, 1) or "").split() 178 self.multi_provider_whitelist = (bb.data.getVar("MULTI_PROVIDER_WHITELIST", cfgData, 1) or "").split()
179 179
180 self.schedulers = set(obj for obj in globals().itervalues()
181 if type(obj) is type and issubclass(obj, RunQueueScheduler))
182
183 user_schedulers = bb.data.getVar("BB_SCHEDULERS", cfgData, True)
184 if user_schedulers:
185 for sched in user_schedulers.split():
186 if not "." in sched:
187 bb.note("Ignoring scheduler '%s' from BB_SCHEDULERS: not an import" % sched)
188 continue
189
190 modname, name = sched.rsplit(".", 1)
191 try:
192 module = __import__(modname, fromlist=(name,))
193 except ImportError, exc:
194 logger.critical("Unable to import scheduler '%s' from '%s': %s" % (name, modname, exc))
195 raise SystemExit(1)
196 else:
197 self.schedulers.add(getattr(module, name))
198
180 self.reset() 199 self.reset()
181 200
182 def reset(self): 201 def reset(self):
@@ -1183,17 +1202,14 @@ class RunQueueExecuteTasks(RunQueueExecute):
1183 1202
1184 event.fire(bb.event.StampUpdate(self.rqdata.target_pairs, self.rqdata.dataCache.stamp), self.cfgData) 1203 event.fire(bb.event.StampUpdate(self.rqdata.target_pairs, self.rqdata.dataCache.stamp), self.cfgData)
1185 1204
1186 schedulers = [obj for obj in globals().itervalues() 1205 for scheduler in self.rqdata.schedulers:
1187 if type(obj) is type and issubclass(obj, RunQueueScheduler)]
1188 for scheduler in schedulers:
1189 if self.scheduler == scheduler.name: 1206 if self.scheduler == scheduler.name:
1190 self.sched = scheduler(self, self.rqdata) 1207 self.sched = scheduler(self, self.rqdata)
1208 bb.msg.debug(1, bb.msg.domain.RunQueue, "Using runqueue scheduler '%s'" % scheduler.name)
1191 break 1209 break
1192 else: 1210 else:
1193 bb.error("Invalid scheduler '%s', using default 'speed' scheduler" % self.scheduler) 1211 bb.fatal("Invalid scheduler '%s'. Available schedulers: %s" %
1194 bb.error("Available schedulers: %s" % ", ".join(obj.name for obj in schedulers)) 1212 (self.scheduler, ", ".join(obj.name for obj in self.rqdata.schedulers)))
1195 self.sched = RunQueueSchedulerSpeed(self, self.rqdata)
1196
1197 1213
1198 def task_completeoutright(self, task): 1214 def task_completeoutright(self, task):
1199 """ 1215 """