我有以下正常功能,它创建Celery Group并尝试在特定时间运行组中的所有子任务:
def run_sms_task_test1(smstask):
if smstask:
phones = []
for user in smstask.userlist.users.all():
phones.append(user.profile.phone)
tasks = []
for phone in phones:
send_sms_async.apply_async([phone, smstask.text], eta=smstask.starts_at)
return None
当我调用此函数而不是定义的'starts_at'时,会触发所有子任务。怎么了?谢谢!
P.S。出于测试原因,我已经编写了一个函数,如果单独启动任务,它对我来说很好:
$query_args = [
'post_type' => 'vehicle',
'post_status' => 'publish'
];
$metaQuery = [
'relation' => 'OR'
];
foreach ($conditions as $condition) {
$metaQuery[] = [
'key' => 'car_condition',
'value' => $condition,
'compare' => '='
];
}
$query_args['meta_query'] = $metaQuery;
答案 0 :(得分:0)
可能是时区问题。
尝试使用以下解决方案
from pytz import timezone
from datetime import datetime
london_tz = pytz.timezone('Europe/London')
london_dt = london_tz.localize(datetime.datetime(year, month, day, hour, min))
starts_at = london_dt.astimezone(pytz.UTC)
result = job.apply_async(eta=starts_at)
希望这对你有帮助。