def __init__(self, queue, config): self._queue = queue """ :type: queue.Queue """ self._session = CacheControl(txrequests.Session()) """ :type: txrequests.Session """ self._config = config """ :type: ldclient.twisted.TwistedConfig """ self._looping_call = None """ :type: LoopingCall"""
def startService(self): # treq only supports basicauth, so we force txrequests if the auth is # something else if self._auth is not None and not isinstance(self._auth, tuple): self.PREFER_TREQ = False if txrequests is not None and not self.PREFER_TREQ: self._session = txrequests.Session() self._doRequest = self._doTxRequest elif treq is None: raise ImportError("{classname} requires either txrequest or treq install." " Users should call {classname}.checkAvailable() during checkConfig()" " to properly alert the user.".format(classname=self.__class__.__name__)) else: self._doRequest = self._doTReq self._pool = HTTPConnectionPool(self.master.reactor) self._pool.maxPersistentPerHost = self.MAX_THREADS self._agent = Agent(self.master.reactor, pool=self._pool)
def sessionFactory(self): """txrequests mocking endpoint""" return txrequests.Session()
def getSession(): global _session if _session is None: _session = txrequests.Session() reactor.addSystemEventTrigger("before", "shutdown", closeSession) return _session
def getSession(): global _session if _session is None: _session = txrequests.Session() return _session