jason810496 commented on code in PR #61310:
URL: https://github.com/apache/airflow/pull/61310#discussion_r2789257453


##########
airflow-core/src/airflow/api_fastapi/app.py:
##########
@@ -137,8 +139,11 @@ def get_auth_manager_cls() -> type[BaseAuthManager]:
 
 def create_auth_manager() -> BaseAuthManager:
     """Create the auth manager."""
-    auth_manager_cls = get_auth_manager_cls()
-    _AuthManagerState.instance = auth_manager_cls()
+    if _AuthManagerState.instance is None:
+        with _AuthManagerState.lock:
+            if _AuthManagerState.instance is None:

Review Comment:
   I indent to add two `if _AuthManagerState.instance is None` check.
   
   The outer check is optimization to avoid taking lock on every call after 
initialization.
   If we have 2 parallel threads that call `create_auth_manager` at the same 
time, the inner check will prevent the second thread from re-initializing once 
the first thread has created the instance.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to