當前位置: 首頁>>代碼示例>>Python>>正文


Python TRequestsTransport.open方法代碼示例

本文整理匯總了Python中apache.aurora.common.transport.TRequestsTransport.open方法的典型用法代碼示例。如果您正苦於以下問題:Python TRequestsTransport.open方法的具體用法?Python TRequestsTransport.open怎麽用?Python TRequestsTransport.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apache.aurora.common.transport.TRequestsTransport的用法示例。


在下文中一共展示了TRequestsTransport.open方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _connect_scheduler

# 需要導入模塊: from apache.aurora.common.transport import TRequestsTransport [as 別名]
# 或者: from apache.aurora.common.transport.TRequestsTransport import open [as 別名]
 def _connect_scheduler(self, uri, clock=time):
   transport = TRequestsTransport(uri, user_agent=self._user_agent)
   protocol = TJSONProtocol.TJSONProtocol(transport)
   schedulerClient = AuroraAdmin.Client(protocol)
   for _ in range(self.THRIFT_RETRIES):
     try:
       transport.open()
       return schedulerClient
     except TTransport.TTransportException:
       clock.sleep(self.RETRY_TIMEOUT.as_(Time.SECONDS))
       continue
     except Exception as e:
       # Monkey-patched proxies, like socks, can generate a proxy error here.
       # without adding a dependency, we can't catch those in a more specific way.
       raise self.CouldNotConnect('Connection to scheduler failed: %s' % e)
   raise self.CouldNotConnect('Could not connect to %s' % uri)
開發者ID:KancerEzeroglu,項目名稱:aurora,代碼行數:18,代碼來源:scheduler_client.py

示例2: _connect_scheduler

# 需要導入模塊: from apache.aurora.common.transport import TRequestsTransport [as 別名]
# 或者: from apache.aurora.common.transport.TRequestsTransport import open [as 別名]
  def _connect_scheduler(self, uri, clock=time):
    transport = TRequestsTransport(
        uri,
        auth=self._auth_handler.auth(),
        user_agent=self._user_agent,
        session_factory=functools.partial(
            _bypass_leader_redirect_session_factory,
            should_bypass=self._bypass_leader_redirect))

    protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
    schedulerClient = AuroraAdmin.Client(protocol)
    for _ in range(self.THRIFT_RETRIES):
      try:
        transport.open()
        return schedulerClient
      except TTransport.TTransportException:
        clock.sleep(self.RETRY_TIMEOUT.as_(Time.SECONDS))
        continue
      except Exception as e:
        # Monkey-patched proxies, like socks, can generate a proxy error here.
        # without adding a dependency, we can't catch those in a more specific way.
        raise self.CouldNotConnect('Connection to scheduler failed: %s' % e)
    raise self.CouldNotConnect('Could not connect to %s' % uri)
開發者ID:bmhatfield,項目名稱:aurora,代碼行數:25,代碼來源:scheduler_client.py

示例3: test_transport_applies_default_user_agent_if_no_factory_provided

# 需要導入模塊: from apache.aurora.common.transport import TRequestsTransport [as 別名]
# 或者: from apache.aurora.common.transport.TRequestsTransport import open [as 別名]
def test_transport_applies_default_user_agent_if_no_factory_provided():
  transport = TRequestsTransport('http://localhost:12345')
  transport.open()
  assert transport._session.headers['User-Agent'] == DEFAULT_USER_AGENT
開發者ID:KancerEzeroglu,項目名稱:aurora,代碼行數:6,代碼來源:test_transport.py

示例4: test_transport_applies_user_agent_from_factory

# 需要導入模塊: from apache.aurora.common.transport import TRequestsTransport [as 別名]
# 或者: from apache.aurora.common.transport.TRequestsTransport import open [as 別名]
def test_transport_applies_user_agent_from_factory():
  user_agent = 'Some-User-Agent'
  transport = TRequestsTransport('http://localhost:12345', user_agent=user_agent)
  transport.open()
  assert transport._session.headers['User-Agent'] == user_agent
開發者ID:KancerEzeroglu,項目名稱:aurora,代碼行數:7,代碼來源:test_transport.py


注:本文中的apache.aurora.common.transport.TRequestsTransport.open方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。