Commit e6deadac authored by Jérome Perrin's avatar Jérome Perrin

testing: fix resource warning with ManagedHTTPServer

We fork a subprocess to serve requests, but the listening socket is bound
in server constructor and inherited by subprocess. With this pattern, we
have to explicitly close the socket from parent process to prevent the
leak.
parent 91edab77
Pipeline #18231 passed with stage
in 0 seconds
......@@ -320,7 +320,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
# type: (str, Type[ManagedResourceType]) -> ManagedResourceType
"""Get the managed resource for this name.
If resouce was not created yet, it is created and `open`. The
If resource was not created yet, it is created and `open`. The
resource will automatically be `close` at the end of the test
class.
"""
......
......@@ -172,6 +172,8 @@ class ManagedHTTPServer(ManagedResource):
name=self._name,
)
self._process.start()
# from now on, socket is used by server subprocess, we can close it
server.socket.close()
def close(self):
# type: () -> None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment