本文整理汇总了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)
示例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)
示例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
示例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