github-actions[bot] commented on code in PR #61280:
URL: https://github.com/apache/doris/pull/61280#discussion_r2929458437


##########
be/src/udf/python/python_server.py:
##########
@@ -814,26 +814,29 @@ class ModuleUDFLoader(UDFLoader):
 
     # Class-level lock dictionary for thread-safe module imports
     # Using RLock allows the same thread to acquire the lock multiple times
-    # Key: (location, module_name) tuple to avoid conflicts between different 
locations
-    _import_locks: Dict[Tuple[str, str], threading.RLock] = {}
+
+    # Key for _import_locks: module_name only (not location)
+    # sys.modules is a global dict keyed by module name. 
+    # we need to ensure that imports with the same module name 
+    # do not interfere with each other across different threads,
+    # even if they come from different file paths.
+    _import_locks: Dict[str, threading.RLock] = {}
     _import_locks_lock = threading.Lock()
+
+    #Key for _module_cache: (location, module_name) tuple to avoid conflicts 
between different locations
     _module_cache: Dict[Tuple[str, str], Any] = {}
     _module_cache_lock = threading.Lock()
 

Review Comment:
   Nit: Missing space after `#`. Should be `# Key for _module_cache: ...`



##########
be/src/udf/python/python_server.py:
##########
@@ -921,7 +924,7 @@ def _get_or_import_module(self, location: str, 
full_module_name: str) -> Any:
         cache_key = (location, full_module_name)
 
         # Use a per-(location, module) lock to prevent race conditions during 
import
-        import_lock = ModuleUDFLoader._get_import_lock(location, 
full_module_name)
+        import_lock = ModuleUDFLoader._get_import_lock(full_module_name)
 

Review Comment:
   Nit: Stale comment. This now uses a per-module lock (not per-(location, 
module) lock). Should be updated to:
   ```python
   # Use a per-module lock to prevent race conditions during import
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to