All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitbake: prserv: fix ResourceWarning due to unclosed socket
@ 2019-11-11 22:15 gavinli
  2019-11-11 22:32 ` ✗ patchtest: failure for " Patchwork
  2019-11-20 16:11 ` [PATCH] " Martin Jansa
  0 siblings, 2 replies; 7+ messages in thread
From: gavinli @ 2019-11-11 22:15 UTC (permalink / raw)
  To: openembedded-core; +Cc: Gavin Li

From: Gavin Li <gavin@matician.com>

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.

Signed-off-by: Gavin Li <gavin@matician.com>
---
 bitbake/lib/prserv/serv.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index be3acec36a..1d9148b817 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -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



^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] bitbake: prserv: fix ResourceWarning due to unclosed socket
@ 2019-11-11 22:17 gavinli
  2019-11-12  7:28 ` Mikko.Rapeli
  0 siblings, 1 reply; 7+ messages in thread
From: gavinli @ 2019-11-11 22:17 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Gavin Li

From: Gavin Li <gavin@matician.com>

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.

Signed-off-by: Gavin Li <gavin@matician.com>
---
 bitbake/lib/prserv/serv.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index be3acec36a..1d9148b817 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-23 14:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 22:15 [PATCH] bitbake: prserv: fix ResourceWarning due to unclosed socket gavinli
2019-11-11 22:32 ` ✗ patchtest: failure for " Patchwork
2019-11-20 16:11 ` [PATCH] " Martin Jansa
2019-11-23 14:01   ` Richard Purdie
2019-11-11 22:17 gavinli
2019-11-12  7:28 ` Mikko.Rapeli
2019-11-12 22:19   ` Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.