summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-05-06 12:34:43 +0000
committerGerrit Code Review <review@openstack.org>2014-05-06 12:34:43 +0000
commit7130f49f1d6a9ecd56d86b4d07b6b20f37fa040f (patch)
tree40dedd1ef059c5c1900d4c0b2cff22cb632248cd
parent05bd34d25bd816a50ef616ca07e276a11f3ba6d5 (diff)
parent0c59ae0f5507cb4af215f27b06fec3f3db3f5b7a (diff)
Merge "Fix a bug when the same method could be run concurrently by 2 threads" into release-0.50.5.0release-0.5
-rw-r--r--muranoapi/dsl/executor.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/muranoapi/dsl/executor.py b/muranoapi/dsl/executor.py
index d63018c..81f5149 100644
--- a/muranoapi/dsl/executor.py
+++ b/muranoapi/dsl/executor.py
@@ -30,6 +30,10 @@ import muranoapi.dsl.murano_object as murano_object
30import muranoapi.dsl.object_store as object_store 30import muranoapi.dsl.object_store as object_store
31import muranoapi.dsl.yaql_functions as yaql_functions 31import muranoapi.dsl.yaql_functions as yaql_functions
32 32
33from muranoapi.openstack.common import log as logging
34
35LOG = logging.getLogger(__name__)
36
33 37
34class MuranoDslExecutor(object): 38class MuranoDslExecutor(object):
35 def __init__(self, class_loader, environment=None): 39 def __init__(self, class_loader, environment=None):
@@ -111,20 +115,30 @@ class MuranoDslExecutor(object):
111 method_id = id(body) 115 method_id = id(body)
112 this_id = this.object_id 116 this_id = this.object_id
113 117
114 event, marker = self._locks.get((method_id, this_id), (None, None)) 118 while True:
115 if event: 119 event, marker = self._locks.get((method_id, this_id), (None, None))
116 if marker == thread_marker: 120 if event:
117 return self._invoke_method_implementation_gt( 121 if marker == thread_marker:
118 body, this, params, murano_class, context) 122 return self._invoke_method_implementation_gt(
119 event.wait() 123 body, this, params, murano_class, context)
124 event.wait()
125 else:
126 break
120 127
121 event = eventlet.event.Event() 128 event = eventlet.event.Event()
122 self._locks[(method_id, this_id)] = (event, thread_marker) 129 self._locks[(method_id, this_id)] = (event, thread_marker)
130 # noinspection PyProtectedMember
131 method_info = "{0}.{1} ({2})".format(murano_class.name, method._name,
132 hash((method_id, this_id)))
133 LOG.debug(
134 "{0}: Begin execution: {1}".format(thread_marker, method_info))
123 gt = eventlet.spawn(self._invoke_method_implementation_gt, body, 135 gt = eventlet.spawn(self._invoke_method_implementation_gt, body,
124 this, params, murano_class, context, 136 this, params, murano_class, context,
125 thread_marker) 137 thread_marker)
126 result = gt.wait() 138 result = gt.wait()
127 del self._locks[(method_id, this_id)] 139 del self._locks[(method_id, this_id)]
140 LOG.debug(
141 "{0}: End execution: {1}".format(thread_marker, method_info))
128 event.send() 142 event.send()
129 return result 143 return result
130 144