Revision 4ab1af1a snf-cyclades-app/synnefo/api/delegate.py

b/snf-cyclades-app/synnefo/api/delegate.py
42 42
USER_CATALOG_URL = getattr(settings, 'CYCLADES_USER_CATALOG_URL', None)
43 43
USER_FEEDBACK_URL = getattr(settings, 'CYCLADES_USER_FEEDBACK_URL', None)
44 44

  
45
from synnefo.lib.pool.http import get_http_connection
45
from synnefo.lib.pool.http import PooledHTTPConnection
46 46

  
47 47
logger = logging.getLogger(__name__)
48 48

  
......
57 57
    kwargs['headers'].setdefault('content-type', 'application/json')
58 58
    kwargs['headers'].setdefault('content-length', len(body) if body else 0)
59 59

  
60
    conn = get_http_connection(p.netloc, p.scheme)
61
    try:
60
    with PooledHTTPConnection(p.netloc, p.scheme) as conn:
62 61
        conn.request(request.method, p.path + '?' + p.query, **kwargs)
63 62
        response = conn.getresponse()
64 63
        length = response.getheader('content-length', None)
65 64
        data = response.read(length)
66 65
        status = int(response.status)
67 66
        return HttpResponse(data, status=status)
68
    finally:
69
        conn.close()
70 67

  
71 68

  
72 69
@csrf_exempt

Also available in: Unified diff