mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
buildstats.py: close /proc/pressure/cpu file descriptor
Use python 'with' symantics to ensure that the /proc/pressure/cpu file descriptor used in SystemStats init is closed. Previously, this would lead to a single file descriptor being leaked. For example: ResourceWarning: unclosed file <_io.BufferedReader name='/proc/pressure/cpu'> (From OE-Core rev: 643653160cd77d346cdc9b9ec25c7212c7dfe176) Signed-off-by: Aryaman Gupta <aryaman.gupta@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
a26721d83b
commit
4678581ea0
@@ -23,8 +23,8 @@ class SystemStats:
|
|||||||
# and ensure that the reduce_proc_pressure directory is not created.
|
# and ensure that the reduce_proc_pressure directory is not created.
|
||||||
if os.path.exists("/proc/pressure"):
|
if os.path.exists("/proc/pressure"):
|
||||||
try:
|
try:
|
||||||
source = open('/proc/pressure/cpu', 'rb')
|
with open('/proc/pressure/cpu', 'rb') as source:
|
||||||
source.read()
|
source.read()
|
||||||
pressuredir = os.path.join(bsdir, 'reduced_proc_pressure')
|
pressuredir = os.path.join(bsdir, 'reduced_proc_pressure')
|
||||||
bb.utils.mkdirhier(pressuredir)
|
bb.utils.mkdirhier(pressuredir)
|
||||||
file_handlers.extend([('pressure/cpu', self._reduce_pressure),
|
file_handlers.extend([('pressure/cpu', self._reduce_pressure),
|
||||||
|
|||||||
Reference in New Issue
Block a user