summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/runqueue.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-07 18:12:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-14 12:52:57 +0100
commit0ee02ca2fa24b0a910a61e4b2ecb55e765735127 (patch)
tree30055e90c194bba79409f76201c7a2e90d109428 /bitbake/lib/bb/runqueue.py
parent026c94be2ea2889a5efc1259cd4f8a33a4a677ef (diff)
downloadpoky-0ee02ca2fa24b0a910a61e4b2ecb55e765735127.tar.gz
bitbake: runqueue: Abstract the start and teardown worker functions
We're going to need a fakeroot/pseudo version of the worker so abstract the code to start the worker process. (Bitbake rev: b5d0f12f9df3ab211700473ed145ee6fbd9ca8e9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/runqueue.py')
-rw-r--r--bitbake/lib/bb/runqueue.py48
1 files changed, 31 insertions, 17 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 34a123b484..3e694ba189 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -800,15 +800,13 @@ class RunQueue:
800 800
801 self.rqexe = None 801 self.rqexe = None
802 self.worker = None 802 self.worker = None
803 self.workerpipe = None
803 804
804 def start_worker(self): 805 def _start_worker(self):
805 if self.worker:
806 self.teardown_worker()
807
808 logger.debug(1, "Starting bitbake-worker") 806 logger.debug(1, "Starting bitbake-worker")
809 self.worker = subprocess.Popen(["bitbake-worker", "decafbad"], stdout=subprocess.PIPE, stdin=subprocess.PIPE) 807 worker = subprocess.Popen(["bitbake-worker", "decafbad"], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
810 bb.utils.nonblockingfd(self.worker.stdout) 808 bb.utils.nonblockingfd(worker.stdout)
811 self.workerpipe = runQueuePipe(self.worker.stdout, None, self.cfgData, self) 809 workerpipe = runQueuePipe(worker.stdout, None, self.cfgData, None)
812 810
813 workerdata = { 811 workerdata = {
814 "taskdeps" : self.rqdata.dataCache.task_deps, 812 "taskdeps" : self.rqdata.dataCache.task_deps,
@@ -825,19 +823,35 @@ class RunQueue:
825 "logdefaultdomain" : bb.msg.loggerDefaultDomains, 823 "logdefaultdomain" : bb.msg.loggerDefaultDomains,
826 } 824 }
827 825
828 self.worker.stdin.write("<cookerconfig>" + pickle.dumps(self.cooker.configuration) + "</cookerconfig>") 826 worker.stdin.write("<cookerconfig>" + pickle.dumps(self.cooker.configuration) + "</cookerconfig>")
829 self.worker.stdin.write("<workerdata>" + pickle.dumps(workerdata) + "</workerdata>") 827 worker.stdin.write("<workerdata>" + pickle.dumps(workerdata) + "</workerdata>")
830 self.worker.stdin.flush() 828 worker.stdin.flush()
831 829
832 def teardown_worker(self): 830 return worker, workerpipe
831
832 def _teardown_worker(self, worker, workerpipe):
833 if not worker:
834 return
833 logger.debug(1, "Teardown for bitbake-worker") 835 logger.debug(1, "Teardown for bitbake-worker")
834 self.worker.stdin.write("<quit></quit>") 836 worker.stdin.write("<quit></quit>")
835 self.worker.stdin.flush() 837 worker.stdin.flush()
836 while self.worker.returncode is None: 838 while worker.returncode is None:
837 self.workerpipe.read() 839 workerpipe.read()
838 self.worker.poll() 840 worker.poll()
839 while self.workerpipe.read(): 841 while workerpipe.read():
840 continue 842 continue
843 workerpipe.close()
844
845 def start_worker(self):
846 if self.worker:
847 self.teardown_worker()
848
849 self.worker, self.workerpipe = self._start_worker()
850
851 def teardown_worker(self):
852 self._teardown_worker(self.worker, self.workerpipe)
853 self.worker = None
854 self.workerpipe = None
841 855
842 def check_stamp_task(self, task, taskname = None, recurse = False, cache = None): 856 def check_stamp_task(self, task, taskname = None, recurse = False, cache = None):
843 def get_timestamp(f): 857 def get_timestamp(f):