From e9652d56ffac0c86db4e21c955b36ded461bda53 Mon Sep 17 00:00:00 2001 From: Bai Date: Mon, 1 Mar 2021 16:30:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96org?= =?UTF-8?q?=E6=97=B6=EF=BC=8Cthread=5Flocal=E7=BC=93=E5=AD=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/orgs/utils.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/orgs/utils.py b/apps/orgs/utils.py index c10a5dacc..e17e7835c 100644 --- a/apps/orgs/utils.py +++ b/apps/orgs/utils.py @@ -84,16 +84,26 @@ def set_org_mapper(org_mapper): def get_org_mapper(): org_mapper = _find('org_mapper') - if org_mapper is None: - org_mapper = construct_org_mapper() - set_org_mapper(org_mapper) + return org_mapper + + +def update_org_mapper(): + org_mapper = construct_org_mapper() + set_org_mapper(org_mapper) return org_mapper def get_org_by_id(org_id): org_id = str(org_id) org_mapper = get_org_mapper() + if not org_mapper: + org_mapper = update_org_mapper() + org = org_mapper.get(org_id) + if not org: + # 解决celery缓存org_mapper问题 + org_mapper = update_org_mapper() + org = org_mapper.get(org_id) return org