本文整理汇总了Python中cloud.aws.CloudHost.should_accept_session方法的典型用法代码示例。如果您正苦于以下问题:Python CloudHost.should_accept_session方法的具体用法?Python CloudHost.should_accept_session怎么用?Python CloudHost.should_accept_session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloud.aws.CloudHost
的用法示例。
在下文中一共展示了CloudHost.should_accept_session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: try_launch_container
# 需要导入模块: from cloud.aws import CloudHost [as 别名]
# 或者: from cloud.aws.CloudHost import should_accept_session [as 别名]
def try_launch_container(cls, user_id):
sessname = unique_sessname(user_id)
cont = JBoxContainer.get_by_name(sessname)
cls.log_debug("have existing container for %s: %r", sessname, None != cont)
if cont is not None:
cls.log_debug("container running: %r", cont.is_running())
if ((cont is None) or (not cont.is_running())) and (not CloudHost.should_accept_session()):
if cont is not None:
cont.async_backup_and_cleanup()
return False
JBoxContainer.async_launch_by_name(sessname, user_id, True)
return True
示例2: try_launch_container
# 需要导入模块: from cloud.aws import CloudHost [as 别名]
# 或者: from cloud.aws.CloudHost import should_accept_session [as 别名]
def try_launch_container(cls, user_id, max_hop=False):
sessname = unique_sessname(user_id)
cont = JBoxContainer.get_by_name(sessname)
cls.log_debug("have existing container for %s: %r", sessname, None != cont)
if cont is not None:
cls.log_debug("container running: %r", cont.is_running())
if max_hop:
self_load = CloudHost.get_instance_stats(CloudHost.instance_id(), 'Load')
if self_load < 100:
JBoxContainer.async_launch_by_name(sessname, user_id, True)
return True
is_leader = is_proposed_cluster_leader()
if ((cont is None) or (not cont.is_running())) and (not CloudHost.should_accept_session(is_leader)):
if cont is not None:
cont.async_backup_and_cleanup()
return False
JBoxContainer.async_launch_by_name(sessname, user_id, True)
return True