From fb78bbfab56416fa16fd39b59fcdb76d53ec7ed5 Mon Sep 17 00:00:00 2001 From: Carrie Arnold Date: Tue, 5 Sep 2023 14:38:20 -0500 Subject: [PATCH] new fresh branch old codebase was stale --- server/portal/apps/auth/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/portal/apps/auth/models.py b/server/portal/apps/auth/models.py index a49e85b29..96bcb2e6a 100644 --- a/server/portal/apps/auth/models.py +++ b/server/portal/apps/auth/models.py @@ -6,6 +6,7 @@ from django.conf import settings from tapipy.tapis import Tapis from django.db import transaction +from threading import Lock logger = logging.getLogger(__name__) @@ -81,7 +82,11 @@ def client(self): with transaction.atomic(): if self.expired: try: - client.refresh_tokens() + lock = Lock() + logger.debug("getting lock") + with lock: + logger.debug("refreshing token with lock") + client.refresh_tokens() except Exception: logger.exception('Tapis Token refresh failed') raise