From 46870f1e26ef159bf6fe4744aba3b00a5e81cc3b Mon Sep 17 00:00:00 2001
From: drebs <drebs@leap.se>
Date: Wed, 8 Jul 2015 19:14:00 -0300
Subject: [feat] add close method for http agent

The ability to close cached connections is needed in order to have a clean
reactor when the program ends.
---
 src/leap/common/http.py | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'src')

diff --git a/src/leap/common/http.py b/src/leap/common/http.py
index d4a214c..8d22f2c 100644
--- a/src/leap/common/http.py
+++ b/src/leap/common/http.py
@@ -80,6 +80,7 @@ class HTTPClient(object):
 
         policy = get_compatible_ssl_context_factory(cert_file)
 
+        self._pool = pool
         self._agent = Agent(
             reactor,
             policy,
@@ -110,6 +111,12 @@ class HTTPClient(object):
         d.addCallback(readBody)
         return d
 
+    def close(self):
+        """
+        Close any cached connections.
+        """
+        self._pool.closeCachedConnections()
+
     class StringBodyProducer(object):
         """
         A producer that writes the body of a request to a consumer.
-- 
cgit v1.2.3