From 0f83df527d6cac2a1eae7fc011ece1fb05daf2a0 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Tue, 8 Oct 2024 13:03:14 -0400 Subject: [PATCH] bitbake: bitbake-server: use with to avoid ResourceWarning Prevents the following warning in bitbake-cookerdaemon.log: 2386729 10:54:16.195427 Exiting (socket: True) 2386729 10:54:16.201065 Exiting as we could obtain the lock sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/laplante/main_yocto/build/bitbake-cookerdaemon.log' mode='a+' encoding='UTF-8'> (Bitbake rev: 8dbf1ec8139d9dd7f52c1773cccbe7696b3ec1b4) Signed-off-by: Chris Laplante Signed-off-by: Richard Purdie --- bitbake/bin/bitbake-server | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitbake/bin/bitbake-server b/bitbake/bin/bitbake-server index 454a3919aa..e367ec2c12 100755 --- a/bitbake/bin/bitbake-server +++ b/bitbake/bin/bitbake-server @@ -38,9 +38,9 @@ if xmlrpcinterface[0] == "None": with open('/dev/null', 'r') as si: os.dup2(si.fileno(), sys.stdin.fileno()) -so = open(logfile, 'a+') -os.dup2(so.fileno(), sys.stdout.fileno()) -os.dup2(so.fileno(), sys.stderr.fileno()) +with open(logfile, 'a+') as so: + os.dup2(so.fileno(), sys.stdout.fileno()) + os.dup2(so.fileno(), sys.stderr.fileno()) # Have stdout and stderr be the same so log output matches chronologically # and there aren't two seperate buffers