Browse Source

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 <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Chris Laplante 7 months ago
parent
commit
0f83df527d
1 changed files with 3 additions and 3 deletions
  1. 3 3
      bitbake/bin/bitbake-server

+ 3 - 3
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