summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-07-05 15:42:25 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-16 12:31:19 +0100
commit8a5b5080a2fa0db7972573cfcd8e04abedb22618 (patch)
tree0264453b6650da4de92bf88e76dcc4562a4d7ea5 /bitbake/lib
parent90db9f30749b3f93a6c7d503af544ee8e0ca1728 (diff)
downloadpoky-8a5b5080a2fa0db7972573cfcd8e04abedb22618.tar.gz
bitbake: runqueue: Combine the waitpid result handling code into a function
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/runqueue.py49
1 files changed, 21 insertions, 28 deletions
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index afbc16a9f0..c82affca3c 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1010,19 +1010,8 @@ class RunQueue:
1010 self.build_pipes[pipe].read() 1010 self.build_pipes[pipe].read()
1011 1011
1012 if self.stats.active > 0: 1012 if self.stats.active > 0:
1013 result = os.waitpid(-1, os.WNOHANG) 1013 if self.runqueue_process_waitpid() is None:
1014 if result[0] is 0 and result[1] is 0:
1015 return 1014 return
1016 task = self.build_pids[result[0]]
1017 del self.build_pids[result[0]]
1018 self.build_pipes[result[0]].close()
1019 del self.build_pipes[result[0]]
1020 if result[1] != 0:
1021 self.task_fail(task, result[1])
1022 return
1023 self.task_complete(task)
1024 self.stats.taskCompleted()
1025 bb.event.fire(runQueueTaskCompleted(task, self.stats, self), self.cfgData)
1026 continue 1015 continue
1027 1016
1028 if len(self.failed_fnids) != 0: 1017 if len(self.failed_fnids) != 0:
@@ -1040,6 +1029,25 @@ class RunQueue:
1040 self.state = runQueueComplete 1029 self.state = runQueueComplete
1041 return 1030 return
1042 1031
1032 def runqueue_process_waitpid(self):
1033 """
1034 Return none is there are no processes awaiting result collection, otherwise
1035 collect the process exit codes and close the information pipe.
1036 """
1037 result = os.waitpid(-1, os.WNOHANG)
1038 if result[0] is 0 and result[1] is 0:
1039 return None
1040 task = self.build_pids[result[0]]
1041 del self.build_pids[result[0]]
1042 self.build_pipes[result[0]].close()
1043 del self.build_pipes[result[0]]
1044 if result[1] != 0:
1045 self.task_fail(task, result[1])
1046 else:
1047 self.task_complete(task)
1048 self.stats.taskCompleted()
1049 bb.event.fire(runQueueTaskCompleted(task, self.stats, self), self.cfgData)
1050
1043 def finish_runqueue_now(self): 1051 def finish_runqueue_now(self):
1044 if self.stats.active: 1052 if self.stats.active:
1045 bb.msg.note(1, bb.msg.domain.RunQueue, "Sending SIGINT to remaining %s tasks" % self.stats.active) 1053 bb.msg.note(1, bb.msg.domain.RunQueue, "Sending SIGINT to remaining %s tasks" % self.stats.active)
@@ -1062,23 +1070,8 @@ class RunQueue:
1062 try: 1070 try:
1063 while self.stats.active > 0: 1071 while self.stats.active > 0:
1064 bb.event.fire(runQueueExitWait(self.stats.active), self.cfgData) 1072 bb.event.fire(runQueueExitWait(self.stats.active), self.cfgData)
1065 #bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % self.stats.active) 1073 if self.runqueue_process_waitpid() is None:
1066 #tasknum = 1
1067 #for k, v in self.build_pids.iteritems():
1068 # bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (pid %s)" % (tasknum, self.get_user_idstring(v), k))
1069 # tasknum = tasknum + 1
1070 result = os.waitpid(-1, os.WNOHANG)
1071 if result[0] is 0 and result[1] is 0:
1072 return 1074 return
1073 task = self.build_pids[result[0]]
1074 del self.build_pids[result[0]]
1075 self.build_pipes[result[0]].close()
1076 del self.build_pipes[result[0]]
1077 if result[1] != 0:
1078 self.task_fail(task, result[1])
1079 else:
1080 self.stats.taskCompleted()
1081 bb.event.fire(runQueueTaskCompleted(task, self.stats, self), self.cfgData)
1082 except: 1075 except:
1083 self.finish_runqueue_now() 1076 self.finish_runqueue_now()
1084 raise 1077 raise