You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2022/05/10 21:38:58 UTC

[libcloud] branch trunk updated (90a7ea3dd -> b9b07c7e1)

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git


    from 90a7ea3dd Use pytest which still supports older Python versions.
     new 43b71091e test/test_http.py: stop HTTP server (thread) properly
     new b9b07c7e1 Also make sure we close the socket so we don't leak open fd.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libcloud/test/test_http.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


[libcloud] 02/02: Also make sure we close the socket so we don't leak open fd.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit b9b07c7e1e49ac8f8fe37e8a1cc2f60d3748f4be
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Tue May 10 23:36:14 2022 +0200

    Also make sure we close the socket so we don't leak open fd.
---
 libcloud/test/test_http.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcloud/test/test_http.py b/libcloud/test/test_http.py
index e9ac5bc19..68ddf9045 100644
--- a/libcloud/test/test_http.py
+++ b/libcloud/test/test_http.py
@@ -118,6 +118,7 @@ class HttpLayerTestCase(unittest.TestCase):
     @classmethod
     def tearDownClass(cls):
         cls.mock_server.shutdown()
+        cls.mock_server.socket.close()
         cls.mock_server_thread.join()
 
     def test_prepared_request_empty_body_chunked_encoding_not_used(self):


[libcloud] 01/02: test/test_http.py: stop HTTP server (thread) properly

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 43b71091ebd159570302b695f0a244f4d0a7e497
Author: Olivier Gayot <ol...@canonical.com>
AuthorDate: Tue May 10 19:16:16 2022 +0200

    test/test_http.py: stop HTTP server (thread) properly
    
    The HttpLayerTestCase test class creates a HTTPServer instance and runs
    it in a separate thread.
    
    After running all the test-cases, we attempt to close the server and the
    thread by killing the thread. Unfortunately, the code that does that is
    unreachable because the tear-down member function is called tearDownCls
    intead of tearDownClass.
    
    Moreover, there is no threading.Thread.kill function. This was undetected
    because the code was unreachable.
    
    The proper way to clean things up is to:
    
    1. Stop the HTTP server using HTTPServer.shutdown()
    2. Join the thread using threading.Thread.join()
---
 libcloud/test/test_http.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/test_http.py b/libcloud/test/test_http.py
index b693f31c2..e9ac5bc19 100644
--- a/libcloud/test/test_http.py
+++ b/libcloud/test/test_http.py
@@ -116,8 +116,9 @@ class HttpLayerTestCase(unittest.TestCase):
         cls.mock_server_thread.start()
 
     @classmethod
-    def tearDownCls(cls):
-        cls.mock_server_thread.kill()
+    def tearDownClass(cls):
+        cls.mock_server.shutdown()
+        cls.mock_server_thread.join()
 
     def test_prepared_request_empty_body_chunked_encoding_not_used(self):
         connection = LibcloudConnection(host=self.listen_host, port=self.listen_port)