本文整理匯總了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