-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb-log-find-hung
executable file
·38 lines (31 loc) · 1.04 KB
/
bb-log-find-hung
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env python3
# Given a bitbake log, identify what tasks are still running by the end.
#
# Helpful when bitbake hangs as there are tasks still executing which have hung.
#
# Licensed under the MIT license
import enum
import sys
import re
import collections
states = enum.Enum("State", "Started Succeeded Failed")
def log_parser(stream):
task_re = re.compile(r"NOTE: recipe (?P<recipe>.+): task (?P<task>.+): (?P<state>\w+)")
for line in stream:
m = task_re.search(line)
if m:
yield states[m.group("state")], m.group("recipe"), m.group("task")
active = collections.Counter()
for state, recipe, task in log_parser(open(sys.argv[1], encoding="utf-8")):
name = recipe + ":" + task
if state == states.Started:
active[name] += 1
elif state in (states.Succeeded, states.Failed):
active[name] -= 1
else:
print(f"ERROR: Unhandled state {state}.")
break
print("Active tasks are:")
for task, count in sorted(active.items()):
if count:
print(f" {task} {count}")