本文整理汇总了Python中cloud.aws.CloudHost.get_email_rates方法的典型用法代码示例。如果您正苦于以下问题:Python CloudHost.get_email_rates方法的具体用法?Python CloudHost.get_email_rates怎么用?Python CloudHost.get_email_rates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloud.aws.CloudHost
的用法示例。
在下文中一共展示了CloudHost.get_email_rates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: auto_activate
# 需要导入模块: from cloud.aws import CloudHost [as 别名]
# 或者: from cloud.aws.CloudHost import get_email_rates [as 别名]
def auto_activate():
try:
num_mails_24h, rate = CloudHost.get_email_rates()
rate_per_second = min(JBoxd.MAX_ACTIVATIONS_PER_SEC, rate)
num_mails = min(JBoxd.MAX_AUTO_ACTIVATIONS_PER_RUN, num_mails_24h)
JBoxd.log_info("Will activate max %d users at %d per second. AWS limits: %d mails at %d per second",
num_mails, rate_per_second,
num_mails_24h, rate)
user_ids = JBoxUserV2.get_pending_activations(num_mails)
JBoxd.log_info("Got %d user_ids to be activated", len(user_ids))
for user_id in user_ids:
JBoxd.log_info("Activating %s", user_id)
# send email by SES
CloudHost.send_email(user_id, JBoxd.ACTIVATION_SENDER, JBoxd.ACTIVATION_SUBJECT, JBoxd.ACTIVATION_BODY)
# set user as activated
user = JBoxUserV2(user_id)
user.set_activation_state(JBoxUserV2.ACTIVATION_CODE_AUTO, JBoxUserV2.ACTIVATION_GRANTED)
user.save()
rate_per_second -= 1
if rate_per_second <= 0:
time.sleep(1)
rate_per_second = min(JBoxd.MAX_ACTIVATIONS_PER_SEC, rate)
finally:
JBoxd.finish_thread()