bitbake: prserv: fix ResourceWarning due to unclosed socket
PATCH v2 1/1 bitbake: prserv: fix ResourceWarning due to unclosed socket
From: Gavin Li <[email protected]>
With PRSERV_HOST = "localhost:0", this message would occasionally pop up during the initial cache read:
WARNING: /home/gavin/yocto/poky/bitbake/lib/bb/cache.py:446: ResourceWarning: unclosed <socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 45655)>
value = pickled.load()
The file location stated is irrelevant; it just happens to be wherever CPython decides to run the garbage collector. The issue is that after we fork off a PRServer, self.socket is also duplicated. The parent side of it also needs to be closed.
Signed-off-by Gavin Li <[email protected]>
--- bitbake/lib/prserv/serv.py | 1 + 1 file changed, 1 insertion(+)
bitbake/lib/prserv/serv.py +1 -0
@@ -243,6 +243,7 @@ class PRServer(SimpleXMLRPCServer): try: pid = os.fork() if pid > 0: + self.socket.close() # avoid ResourceWarning in parent return pid except OSError as e: raise Exception("%s [%d]" % (e.strerror, e.errno))
Signature · 1 line
2.23.0