incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1432086 - /incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/hooks.py
Date Fri, 11 Jan 2013 15:16:39 GMT
Author: jure
Date: Fri Jan 11 15:16:39 2013
New Revision: 1432086

URL: http://svn.apache.org/viewvc?rev=1432086&view=rev
Log:
#323, only install global hooks once


Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/hooks.py

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/hooks.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/hooks.py?rev=1432086&r1=1432085&r2=1432086&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/hooks.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/hooks.py Fri Jan 11 15:16:39
2013
@@ -20,6 +20,7 @@ import imp
 import inspect
 
 from config import Configuration
+from util.concurrency import threading
 
 __all__ = ['environment_factory', 'install_global_hooks']
 
@@ -53,14 +54,26 @@ def _get_hook_class(env_path, hook_path,
             return cls
     return None
 
+_global_hooks_installed = False
+_global_hooks_lock = threading.Lock()
+
 def install_global_hooks(environ, env_path):
-    config = _get_config(env_path)
-    hook_paths = config.get('trac', 'global_hooks', default=None)
-    if hook_paths:
-        for hook_path in hook_paths.split(','):
-            cls = _get_hook_class(env_path, hook_path, GlobalHooksBase)
-            if cls:
-                cls().install_hooks(environ, env_path)
+    global _global_hooks_installed, _global_hooks_lock
+    if _global_hooks_installed:
+        return
+    _global_hooks_lock.acquire()
+    try:
+        if not _global_hooks_installed:
+            config = _get_config(env_path)
+            hook_paths = config.get('trac', 'global_hooks', default=None)
+            if hook_paths:
+                for hook_path in hook_paths.split(','):
+                    cls = _get_hook_class(env_path, hook_path, GlobalHooksBase)
+                    if cls:
+                        cls().install_hooks(environ, env_path)
+            _global_hooks_installed = True
+    finally:
+        _global_hooks_lock.release()
     return
 
 def environment_factory(env):



Mime
View raw message