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