ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: removed sleep, and added some complexity to the caching mechanism
Date Sun, 12 Mar 2017 14:32:12 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-117-Log-model-should-have-an-Task-field 62f01414a -> 7cb97a7cc


removed sleep, and added some complexity to the caching mechanism


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/7cb97a7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/7cb97a7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/7cb97a7c

Branch: refs/heads/ARIA-117-Log-model-should-have-an-Task-field
Commit: 7cb97a7cc2dbdd503f2f793f7bccfd57f4eea1c0
Parents: 62f0141
Author: max-orlov <maxim@gigaspaces.com>
Authored: Sun Mar 12 16:32:08 2017 +0200
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Sun Mar 12 16:32:08 2017 +0200

----------------------------------------------------------------------
 aria/orchestrator/context/operation.py         | 9 ++++++++-
 aria/orchestrator/workflows/executor/thread.py | 3 ---
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7cb97a7c/aria/orchestrator/context/operation.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/operation.py b/aria/orchestrator/context/operation.py
index ed0791c..acbf94d 100644
--- a/aria/orchestrator/context/operation.py
+++ b/aria/orchestrator/context/operation.py
@@ -17,6 +17,8 @@
 Workflow and operation contexts
 """
 
+import threading
+
 import aria
 from aria.utils import file
 from .common import BaseContext
@@ -47,6 +49,7 @@ class BaseOperationContext(BaseContext):
         self._task = None
         self._execution_id = execution_id
         self._register_logger(task_id=self.task.id)
+        self._current_thread = threading.current_thread()
 
     def __repr__(self):
         details = 'implementation={task.implementation}; ' \
@@ -64,8 +67,12 @@ class BaseOperationContext(BaseContext):
         The task in the model storage
         :return: Task model
         """
-        if not self._task:
+        # SQLAlchemy prevents from accessing an object which was created on a different thread.
+        # So we retrieve the object from the storage if the current thread isn't the same
as the
+        # original thread.
+        if not self._task or threading.current_thread() != self._current_thread:
             self._task = self.model.task.get(self._task_id)
+            self._current_thread = threading.current_thread()
         return self._task
 
     @property

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/7cb97a7c/aria/orchestrator/workflows/executor/thread.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/thread.py b/aria/orchestrator/workflows/executor/thread.py
index 16b22e3..3189801 100644
--- a/aria/orchestrator/workflows/executor/thread.py
+++ b/aria/orchestrator/workflows/executor/thread.py
@@ -59,9 +59,6 @@ class ThreadExecutor(BaseExecutor):
                 self._task_started(task)
                 try:
                     task_func = imports.load_attribute(task.implementation)
-                    # Some of the changes (mainly the logs fail to propagate if not enough
time
-                    # is given
-                    time.sleep(0.1)
                     task_func(ctx=task.context, **task.inputs)
                     self._task_succeeded(task)
                 except BaseException as e:


Mime
View raw message