bitbake: prserv: fix ResourceWarning due to unclosed socket
PATCH 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/matic/ambayocto/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.
--- 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
Hi,
Quoted 4 lines · On Mon, Nov 11, 2019 at 02:17:39PM -0800, [email protected] wrote:
From: Gavin Li <[email protected]>
With
PRSERV_HOST= "localhost:0", this message would occasionally pop up during the initial cache read:
Thanks for this fix!
It's not occasionally, it's all the time with zeus and Debian build container...
If it helps:
-Mikko
Quoted 33 lines
WARNING:
/home/matic/ambayocto/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 · 7 lines
2.23.0 -- _______________________________________________ bitbake-devel mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/bitbake-devel
Quoted 11 lines
-----Original Message-----
From: [email protected] <bitbake-devel- [email protected]> On Behalf Of [email protected]
Sent: den 12 november 2019 08:29
To: [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [bitbake-devel] [PATCH] bitbake: prserv: fix ResourceWarning due to unclosed socketHi,
Quoted 7 lines
Quoted 4 lines · On Mon, Nov 11, 2019 at 02:17:39PM -0800, [email protected] wrote:
From: Gavin Li <[email protected]>
With
PRSERV_HOST= "localhost:0", this message would occasionally pop up during the initial cache read:Thanks for this fix!
Yes, finally! I've been hunting this for quite a while...
Quoted 2 lines
It's not occasionally, it's all the time with zeus and Debian build container...
It is occasional for Warrior, so I guess it should be backported to both Zeus and Warrior.
Quoted 4 lines
If it helps:
Tested-by Mikko Rapeli <[email protected]>-Mikko
//Peter
Quoted 30 lines
Quoted 1 line
WARNING:
/home/matic/ambayocto/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)>
Quoted 26 lines
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
-1@@ -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)) --2.23.0