修复定时任务多线程数据共享异常

dependabot/npm_and_yarn/fir_admin/async-2.6.4
nineven 3 years ago
parent d1a41a179b
commit bc0cee937d
  1. 62
      fir_ser/common/libs/sendmsg/templates/check_developer.html
  2. 8
      fir_ser/xsign/utils/ctasks.py

@ -150,37 +150,39 @@
<div> <div>
昨天消耗设备数:{{ yesterday_used_number }} 昨天消耗设备数:{{ yesterday_used_number }}
</div> </div>
<table class="table table-bordered table-striped"> <div style="margin-top: 10px">
<thead> <table class="table table-bordered table-striped">
<tr> <thead>
<th> <tr>
苹果开发者ID <th>
</th> 苹果开发者ID
<th> </th>
苹果开发者备注 <th>
</th> 苹果开发者备注
<th> </th>
苹果开发者状态 <th>
</th> 苹果开发者状态
</tr> </th>
</thead>
<tbody>
{% for developer_obj in developer_obj_list %}
<tr class="{% if developer_obj.status == 2 %}table-warning{% elif developer_obj.status == 1 %}table-success{% else %}table-danger{% endif %}">
<td>
{{ developer_obj.issuer_id }}
</td>
<td>
{{ developer_obj.description }}
</td>
<td>
{{ developer_obj.get_status_display }}
</td>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for developer_obj in developer_obj_list %}
<tr class="{% if developer_obj.status == 2 %}table-warning{% elif developer_obj.status == 1 %}table-success{% else %}table-danger{% endif %}">
<td>
{{ developer_obj.issuer_id }}
</td>
<td>
{{ developer_obj.description }}
</td>
<td>
{{ developer_obj.get_status_display }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</body> </body>

@ -42,14 +42,12 @@ def auto_check_ios_developer_active():
def check_active_task(developer_obj): def check_active_task(developer_obj):
time.sleep(random.randint(1, 5)) time.sleep(random.randint(1, 5))
user_obj = developer_obj.user_id user_obj = developer_obj.user_id
err_issuer_id = error_issuer_id.get(user_obj.uid, [])
if user_obj.supersign_active: if user_obj.supersign_active:
status, result = IosUtils.active_developer(developer_obj, False) status, result = IosUtils.active_developer(developer_obj, False)
msg = f"auto_check_ios_developer_active user:{user_obj} ios.developer:{developer_obj} status:{status} result:{result}" msg = f"auto_check_ios_developer_active user:{user_obj} ios.developer:{developer_obj} status:{status} result:{result}"
if not status: if not status:
add_sign_message(user_obj, developer_obj, None, '开发者状态自动检测', result.get('return_info'), False) add_sign_message(user_obj, developer_obj, None, '开发者状态自动检测', result.get('return_info'), False)
err_issuer_id.append(developer_obj) error_issuer_id[user_obj.uid].append(developer_obj)
error_issuer_id[user_obj.uid] = list(set(err_issuer_id))
if status: if status:
IosUtils.get_device_from_developer(developer_obj) IosUtils.get_device_from_developer(developer_obj)
@ -62,6 +60,9 @@ def auto_check_ios_developer_active():
user_id__supersign_active=True) user_id__supersign_active=True)
pools = ThreadPoolExecutor(10) pools = ThreadPoolExecutor(10)
for user_uid in ios_developer_queryset.values('user_id__uid').all().distinct():
error_issuer_id[user_uid.get('user_id__uid', 'default')] = []
for ios_developer_obj in ios_developer_queryset: for ios_developer_obj in ios_developer_queryset:
pools.submit(check_active_task, ios_developer_obj) pools.submit(check_active_task, ios_developer_obj)
pools.shutdown() pools.shutdown()
@ -74,6 +75,7 @@ def auto_check_ios_developer_active():
start_time = end_time - datetime.timedelta(days=1) start_time = end_time - datetime.timedelta(days=1)
yesterday_used_number = APPSuperSignUsedInfo.objects.filter(developerid__user_id=userinfo, yesterday_used_number = APPSuperSignUsedInfo.objects.filter(developerid__user_id=userinfo,
created_time__range=[start_time, end_time]).count() created_time__range=[start_time, end_time]).count()
developer_obj_list = sorted(developer_obj_list, key=lambda obj: obj.status)
content = loader.render_to_string('check_developer.html', content = loader.render_to_string('check_developer.html',
{ {
'username': userinfo.first_name, 'username': userinfo.first_name,

Loading…
Cancel
Save