当前位置: 首页>>代码示例>>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;未经允许,请勿转载。