diff options
author | Chris Laplante <chris.laplante@agilent.com> | 2020-09-09 12:55:30 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-10 13:49:21 +0100 |
commit | 926c154eb444c533a2f47a7cdf63667d78d30794 (patch) | |
tree | 066930f401c9dbb9735ff34b48cdabaad5a3baef /bitbake/lib | |
parent | d58504b097d31b03cfa39496571f9f037be3e091 (diff) | |
download | poky-926c154eb444c533a2f47a7cdf63667d78d30794.tar.gz |
bitbake: utils: process_profilelog: use context manager
(Bitbake rev: 42172900af06baeee559d33b150d5febdf8e960a)
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/utils.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index e51b8ca508..2d4b258b85 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -1071,21 +1071,20 @@ def process_profilelog(fn, pout = None): | |||
1071 | # Either call with a list of filenames and set pout or a filename and optionally pout. | 1071 | # Either call with a list of filenames and set pout or a filename and optionally pout. |
1072 | if not pout: | 1072 | if not pout: |
1073 | pout = fn + '.processed' | 1073 | pout = fn + '.processed' |
1074 | pout = open(pout, 'w') | 1074 | |
1075 | 1075 | with open(pout, 'w') as pout: | |
1076 | import pstats | 1076 | import pstats |
1077 | if isinstance(fn, list): | 1077 | if isinstance(fn, list): |
1078 | p = pstats.Stats(*fn, stream=pout) | 1078 | p = pstats.Stats(*fn, stream=pout) |
1079 | else: | 1079 | else: |
1080 | p = pstats.Stats(fn, stream=pout) | 1080 | p = pstats.Stats(fn, stream=pout) |
1081 | p.sort_stats('time') | 1081 | p.sort_stats('time') |
1082 | p.print_stats() | 1082 | p.print_stats() |
1083 | p.print_callers() | 1083 | p.print_callers() |
1084 | p.sort_stats('cumulative') | 1084 | p.sort_stats('cumulative') |
1085 | p.print_stats() | 1085 | p.print_stats() |
1086 | 1086 | ||
1087 | pout.flush() | 1087 | pout.flush() |
1088 | pout.close() | ||
1089 | 1088 | ||
1090 | # | 1089 | # |
1091 | # Was present to work around multiprocessing pool bugs in python < 2.7.3 | 1090 | # Was present to work around multiprocessing pool bugs in python < 2.7.3 |