summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/uihelper.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-12-03 22:01:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-12-06 14:39:29 +0000
commitccd7f12b1c95b546ef79204ad0832b88a595d0ea (patch)
tree04cd240e7ca62459392b8483ba3f631574524fc2 /bitbake/lib/bb/ui/uihelper.py
parent109ef2e5c4161a2c0ac58bede3daa48c7b4881ec (diff)
downloadpoky-ccd7f12b1c95b546ef79204ad0832b88a595d0ea.tar.gz
bitbake: knotty/uihelper: Switch from pids to tids for Task event management
We've seen cases where a task can execute with a given pid, complete and a new task can start using the same pid before the UI handler has had time to adapt. Traceback (most recent call last): File "/home/pokybuild/yocto-worker/qemux86-alt/build/bitbake/lib/bb/ui/knotty.py", line 484, in main helper.eventHandler(event) File "/home/pokybuild/yocto-worker/qemux86-alt/build/bitbake/lib/bb/ui/uihelper.py", line 30, in eventHandler del self.running_tasks[event.pid] KeyError: 13490 This means using pids to match up events on the UI side is a bad idea. Change the code to use task ids instead. There is a small amount of fuzzy matching for the progress information since there is no task information there and we don't want the overhead of a task ID in every event, however since pid reuse is unlikely, we can live with a progress bar not quite working properly in a corner case like this. [YOCTO #13667] (Bitbake rev: e427eafa1bb04008d12100ccc5c862122bba53e0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/uihelper.py')
-rw-r--r--bitbake/lib/bb/ui/uihelper.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/bitbake/lib/bb/ui/uihelper.py b/bitbake/lib/bb/ui/uihelper.py
index c8dd7df087..48d808ae28 100644
--- a/bitbake/lib/bb/ui/uihelper.py
+++ b/bitbake/lib/bb/ui/uihelper.py
@@ -15,39 +15,48 @@ class BBUIHelper:
15 # Running PIDs preserves the order tasks were executed in 15 # Running PIDs preserves the order tasks were executed in
16 self.running_pids = [] 16 self.running_pids = []
17 self.failed_tasks = [] 17 self.failed_tasks = []
18 self.pidmap = {}
18 self.tasknumber_current = 0 19 self.tasknumber_current = 0
19 self.tasknumber_total = 0 20 self.tasknumber_total = 0
20 21
21 def eventHandler(self, event): 22 def eventHandler(self, event):
23 # PIDs are a bad idea as they can be reused before we process all UI events.
24 # We maintain a 'fuzzy' match for TaskProgress since there is no other way to match
25 def removetid(pid, tid):
26 self.running_pids.remove(tid)
27 del self.running_tasks[tid]
28 if self.pidmap[pid] == tid:
29 del self.pidmap[pid]
30 self.needUpdate = True
31
22 if isinstance(event, bb.build.TaskStarted): 32 if isinstance(event, bb.build.TaskStarted):
33 tid = event._fn + ":" + event._task
23 if event._mc != "default": 34 if event._mc != "default":
24 self.running_tasks[event.pid] = { 'title' : "mc:%s:%s %s" % (event._mc, event._package, event._task), 'starttime' : time.time() } 35 self.running_tasks[tid] = { 'title' : "mc:%s:%s %s" % (event._mc, event._package, event._task), 'starttime' : time.time(), 'pid' : event.pid }
25 else: 36 else:
26 self.running_tasks[event.pid] = { 'title' : "%s %s" % (event._package, event._task), 'starttime' : time.time() } 37 self.running_tasks[tid] = { 'title' : "%s %s" % (event._package, event._task), 'starttime' : time.time(), 'pid' : event.pid }
27 self.running_pids.append(event.pid) 38 self.running_pids.append(tid)
39 self.pidmap[event.pid] = tid
28 self.needUpdate = True 40 self.needUpdate = True
29 elif isinstance(event, bb.build.TaskSucceeded): 41 elif isinstance(event, bb.build.TaskSucceeded):
30 del self.running_tasks[event.pid] 42 tid = event._fn + ":" + event._task
31 self.running_pids.remove(event.pid) 43 removetid(event.pid, tid)
32 self.needUpdate = True
33 elif isinstance(event, bb.build.TaskFailedSilent): 44 elif isinstance(event, bb.build.TaskFailedSilent):
34 del self.running_tasks[event.pid] 45 tid = event._fn + ":" + event._task
35 self.running_pids.remove(event.pid) 46 removetid(event.pid, tid)
36 # Don't add to the failed tasks list since this is e.g. a setscene task failure 47 # Don't add to the failed tasks list since this is e.g. a setscene task failure
37 self.needUpdate = True
38 elif isinstance(event, bb.build.TaskFailed): 48 elif isinstance(event, bb.build.TaskFailed):
39 del self.running_tasks[event.pid] 49 tid = event._fn + ":" + event._task
40 self.running_pids.remove(event.pid) 50 removetid(event.pid, tid)
41 self.failed_tasks.append( { 'title' : "%s %s" % (event._package, event._task)}) 51 self.failed_tasks.append( { 'title' : "%s %s" % (event._package, event._task)})
42 self.needUpdate = True
43 elif isinstance(event, bb.runqueue.runQueueTaskStarted): 52 elif isinstance(event, bb.runqueue.runQueueTaskStarted):
44 self.tasknumber_current = event.stats.completed + event.stats.active + event.stats.failed + 1 53 self.tasknumber_current = event.stats.completed + event.stats.active + event.stats.failed + 1
45 self.tasknumber_total = event.stats.total 54 self.tasknumber_total = event.stats.total
46 self.needUpdate = True 55 self.needUpdate = True
47 elif isinstance(event, bb.build.TaskProgress): 56 elif isinstance(event, bb.build.TaskProgress):
48 if event.pid > 0: 57 if event.pid > 0 and event.pid in self.pidmap:
49 self.running_tasks[event.pid]['progress'] = event.progress 58 self.running_tasks[self.pidmap[event.pid]]['progress'] = event.progress
50 self.running_tasks[event.pid]['rate'] = event.rate 59 self.running_tasks[self.pidmap[event.pid]]['rate'] = event.rate
51 self.needUpdate = True 60 self.needUpdate = True
52 else: 61 else:
53 return False 62 return False