##// END OF EJS Templates
threading: Add factory that creates curl session for each thread....
Martin Bornhold -
r243:dae685be default
parent child Browse files
Show More
@@ -31,6 +31,7 b' implementation.'
31
31
32 import copy
32 import copy
33 import logging
33 import logging
34 import threading
34 import urllib2
35 import urllib2
35 import urlparse
36 import urlparse
36 import uuid
37 import uuid
@@ -38,7 +39,7 b' import uuid'
38 import msgpack
39 import msgpack
39 import requests
40 import requests
40
41
41 from . import exceptions
42 from . import exceptions, CurlSession
42
43
43
44
44 log = logging.getLogger(__name__)
45 log = logging.getLogger(__name__)
@@ -216,3 +217,17 b' class VcsHttpProxy(object):'
216 headers = iterator.next()
217 headers = iterator.next()
217
218
218 return iterator, status, headers
219 return iterator, status, headers
220
221
222 class ThreadlocalSessionFactory(object):
223 """
224 Creates one CurlSession per thread on demand.
225 """
226
227 def __init__(self):
228 self._thread_local = threading.local()
229
230 def __call__(self):
231 if not hasattr(self._thread_local, 'curl_session'):
232 self._thread_local.curl_session = CurlSession()
233 return self._thread_local.curl_session
General Comments 0
You need to be logged in to leave comments. Login now