test_class.declarator: shouldRunMaven
test_class.modifier: private static
test_class.original_string: private static boolean shouldRunMaven;
test_class.type: boolean
test_class.var_name: shouldRunMaven
test_class.declarator: LINE_SEPARATOR = System.lineSeparator()
test_class.modifier: private static
test_class.original_string: private static String LINE_SEPARATOR = System.lineSeparator();
test_class.type: String
test_class.var_name: LINE_SEPARATOR
test_class.declarator: SYSTEM_PROPERTIES_MAP = "__sys_prop__"
test_class.modifier: private static final
test_class.original_string: private static final String SYSTEM_PROPERTIES_MAP = "__sys_prop__";
test_class.type: String
test_class.var_name: SYSTEM_PROPERTIES_MAP
test_class.declarator: GET_SP_FUNCTION_DEFINITION =
              "import time" + LINE_SEPARATOR +
                      "def check_env(sysPropName, expectedSysPropValue, variable, expectedVariableValue):" + LINE_SEPARATOR +
                      "  time.sleep(3)" + LINE_SEPARATOR +
                      "  property_value = __sys_prop__.get(sysPropName)" + LINE_SEPARATOR +
                      "  print 'sysProperty: found ' + property_value + ', expected ' + expectedSysPropValue" + LINE_SEPARATOR +
                      "  global_variable_value = globals().get(variable)" + LINE_SEPARATOR +
                      "  print 'global variable: found ' + str(global_variable_value) + ', expected ' + expectedVariableValue" + LINE_SEPARATOR +
                      "  EXPECTED=expectedVariableValue" + LINE_SEPARATOR +
                      "  ACTUAL=property_value" + LINE_SEPARATOR +
                      "  return expectedSysPropValue + ':' + property_value + ',' + expectedVariableValue + ':' + global_variable_value"
test_class.modifier: private static final
test_class.original_string: private static final String GET_SP_FUNCTION_DEFINITION =
              "import time" + LINE_SEPARATOR +
                      "def check_env(sysPropName, expectedSysPropValue, variable, expectedVariableValue):" + LINE_SEPARATOR +
                      "  time.sleep(3)" + LINE_SEPARATOR +
                      "  property_value = __sys_prop__.get(sysPropName)" + LINE_SEPARATOR +
                      "  print 'sysProperty: found ' + property_value + ', expected ' + expectedSysPropValue" + LINE_SEPARATOR +
                      "  global_variable_value = globals().get(variable)" + LINE_SEPARATOR +
                      "  print 'global variable: found ' + str(global_variable_value) + ', expected ' + expectedVariableValue" + LINE_SEPARATOR +
                      "  EXPECTED=expectedVariableValue" + LINE_SEPARATOR +
                      "  ACTUAL=property_value" + LINE_SEPARATOR +
                      "  return expectedSysPropValue + ':' + property_value + ',' + expectedVariableValue + ':' + global_variable_value";
test_class.type: String
test_class.var_name: GET_SP_FUNCTION_DEFINITION
test_class.declarator: VAR1 = "VAR1"
test_class.modifier: private static final
test_class.original_string: private static final String VAR1 = "VAR1";
test_class.type: String
test_class.var_name: VAR1
test_class.declarator: VAR2 = "VAR2"
test_class.modifier: private static final
test_class.original_string: private static final String VAR2 = "VAR2";
test_class.type: String
test_class.var_name: VAR2
test_class.declarator: EXECUTION_SCRIPT =
              "import sys" + LINE_SEPARATOR +
                      "import time" + LINE_SEPARATOR +
                      "time.sleep(3)" + LINE_SEPARATOR +
                      VAR1 + "={0}" + LINE_SEPARATOR +
                      VAR2 + "={1}" + LINE_SEPARATOR +
                      "print ''VAR1='' + str(" + VAR1 + ")" + LINE_SEPARATOR +
                      "print ''VAR2='' + str(" + VAR2 + ")" + LINE_SEPARATOR
test_class.modifier: private static final
test_class.original_string: private static final String EXECUTION_SCRIPT =
              "import sys" + LINE_SEPARATOR +
                      "import time" + LINE_SEPARATOR +
                      "time.sleep(3)" + LINE_SEPARATOR +
                      VAR1 + "={0}" + LINE_SEPARATOR +
                      VAR2 + "={1}" + LINE_SEPARATOR +
                      "print ''VAR1='' + str(" + VAR1 + ")" + LINE_SEPARATOR +
                      "print ''VAR2='' + str(" + VAR2 + ")" + LINE_SEPARATOR;
test_class.type: String
test_class.var_name: EXECUTION_SCRIPT
test_class.declarator: PY_CLASS_IS_EXCLUDED_SCRIPT =
              "from Queue import Queue" + LINE_SEPARATOR +
                      "x = 'abc'" + LINE_SEPARATOR
test_class.modifier: private static final
test_class.original_string: private static final String PY_CLASS_IS_EXCLUDED_SCRIPT =
              "from Queue import Queue" + LINE_SEPARATOR +
                      "x = 'abc'" + LINE_SEPARATOR;
test_class.type: String
test_class.var_name: PY_CLASS_IS_EXCLUDED_SCRIPT
test_class.declarator: EMPTY_CALL_ARGUMENTS = Collections.emptyMap()
test_class.modifier: private static final
test_class.original_string: private static final Map<String, Serializable> EMPTY_CALL_ARGUMENTS = Collections.emptyMap();
test_class.type: Map<String, Serializable>
test_class.var_name: EMPTY_CALL_ARGUMENTS
test_class.declarator: EXPECTED_CONTEXT_EXEC
test_class.modifier: private static final
test_class.original_string: private static final Map<String, Serializable> EXPECTED_CONTEXT_EXEC;
test_class.type: Map<String, Serializable>
test_class.var_name: EXPECTED_CONTEXT_EXEC
test_class.declarator: EXPECTED_CONTEXT_EVAL
test_class.modifier: private static final
test_class.original_string: private static final Map<String, Serializable> EXPECTED_CONTEXT_EVAL;
test_class.type: Map<String, Serializable>
test_class.var_name: EXPECTED_CONTEXT_EVAL
test_class.declarator: pythonRuntimeService
test_class.modifier: @Resource(name = "jythonRuntimeService")
      private
test_class.original_string: @Resource(name = "jythonRuntimeService")
      private PythonRuntimeService pythonRuntimeService;
test_class.type: PythonRuntimeService
test_class.var_name: pythonRuntimeService
test_class.file: runtime-management/runtime-management-impl/src/test/java/io/cloudslang/runtime/impl/python/PythonExecutorTest.java
test_class.identifier: PythonExecutorTest
test_case.body: @Test
      public void testMultithreadedExecWithDependencies() throws InterruptedException {
          Assume.assumeTrue(shouldRunMaven);
          int executionsNum = 5;
  
          final CountDownLatch latch = new CountDownLatch(executionsNum);
  
          final String [] dependencies = {
                  new File(getClass().getClassLoader().getResource(".m2/repository/python/math2/mult/1.0/mult-1.0.zip").getFile()).getAbsolutePath(),
                  new File(getClass().getClassLoader().getResource(".m2/repository/python/math2/sum/2.1/sum-2.1.zip").getFile()).getAbsolutePath(),
                  new File(getClass().getClassLoader().getResource(".m2/repository/python/math3/mult/1.2/mult-1.2.zip").getFile()).getAbsolutePath(),
                  new File(getClass().getClassLoader().getResource(".m2/repository/python/math3/sum/4.1/sum-4.1.zip").getFile()).getAbsolutePath()
          };
  
          for(int i = 0; i < executionsNum; i++) {
              final String executioId = String.valueOf(i);
              final String varName = "VAR";
              final String script = "import sys\nimport time\nimport math_fake.utils.print_text as print_text\ntime.sleep(3)\n" + varName + " = print_text.foo('" + executioId + "')\nprint " + varName + "\n";
              final String dependency = dependencies[i % 4];
  
              int count = dependency.contains("math2") ? 2 : 3;
              String sign = dependency.contains("sum-") ? "+" : "*";
  
              final StringBuilder expectedResult = new StringBuilder(executioId);
              while (--count > 0) {
                  expectedResult.append(sign).append(executioId);
              }
  
              new Thread() {
                  public void run() {
                      try {
                          PythonExecutionResult result = pythonRuntimeService.exec(new HashSet<>(Collections.singletonList(dependency)), script, EMPTY_CALL_ARGUMENTS);
                          assertNotNull(result);
                          assertNotNull(result.getExecutionResult().get(varName));
                          assertEquals(expectedResult.toString(), result.getExecutionResult().get(varName).toString());
                      } finally {
                          latch.countDown();
                      }
                  }
              }.start();
          }
          latch.await();
      }
test_case.class_method_signature: PythonExecutorTest.testMultithreadedExecWithDependencies()
test_case.full_signature: @Test public void testMultithreadedExecWithDependencies()
test_case.identifier: testMultithreadedExecWithDependencies
test_case.invocations: assumeTrue getAbsolutePath getFile getResource getClassLoader getClass getAbsolutePath getFile getResource getClassLoader getClass getAbsolutePath getFile getResource getClassLoader getClass getAbsolutePath getFile getResource getClassLoader getClass valueOf contains contains append append start exec singletonList assertNotNull assertNotNull get getExecutionResult assertEquals toString toString get getExecutionResult countDown await
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMultithreadedExecWithDependencies()
focal_class.declarator: THREADED_MODULES_ISSUE = "No module named"
focal_class.modifier: public static final
focal_class.original_string: public static final String THREADED_MODULES_ISSUE = "No module named";
focal_class.type: String
focal_class.var_name: THREADED_MODULES_ISSUE
focal_class.declarator: logger = Logger.getLogger(PythonExecutor.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(PythonExecutor.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: TRUE = "true"
focal_class.modifier: private static final
focal_class.original_string: private static final String TRUE = "true";
focal_class.type: String
focal_class.var_name: TRUE
focal_class.declarator: FALSE = "false"
focal_class.modifier: private static final
focal_class.original_string: private static final String FALSE = "false";
focal_class.type: String
focal_class.var_name: FALSE
focal_class.declarator: GLOBAL_INTERPRETER = new ThreadSafePythonInterpreter(null)
focal_class.modifier: private static final
focal_class.original_string: private static final PythonInterpreter GLOBAL_INTERPRETER = new ThreadSafePythonInterpreter(null);
focal_class.type: PythonInterpreter
focal_class.var_name: GLOBAL_INTERPRETER
focal_class.declarator: RETRIES_NUMBER_ON_THREADED_ISSUE = 3
focal_class.modifier: public static final
focal_class.original_string: public static final int RETRIES_NUMBER_ON_THREADED_ISSUE = 3;
focal_class.type: int
focal_class.var_name: RETRIES_NUMBER_ON_THREADED_ISSUE
focal_class.declarator: MAX_LENGTH = Integer.getInteger("input.error.max.length", 1000)
focal_class.modifier: public static final
focal_class.original_string: public static final int MAX_LENGTH = Integer.getInteger("input.error.max.length", 1000);
focal_class.type: int
focal_class.var_name: MAX_LENGTH
focal_class.declarator: interpreter
focal_class.modifier: private final
focal_class.original_string: private final PythonInterpreter interpreter;
focal_class.type: PythonInterpreter
focal_class.var_name: interpreter
focal_class.declarator: allocationLock = new ReentrantLock()
focal_class.modifier: private final
focal_class.original_string: private final Lock allocationLock = new ReentrantLock();
focal_class.type: Lock
focal_class.var_name: allocationLock
focal_class.declarator: allocations = 0
focal_class.modifier: private
focal_class.original_string: private int allocations = 0;
focal_class.type: int
focal_class.var_name: allocations
focal_class.declarator: markedClosed = false
focal_class.modifier: private
focal_class.original_string: private boolean markedClosed = false;
focal_class.type: boolean
focal_class.var_name: markedClosed
focal_class.declarator: actuallyClosed = false
focal_class.modifier: private
focal_class.original_string: private boolean actuallyClosed = false;
focal_class.type: boolean
focal_class.var_name: actuallyClosed
focal_class.declarator: dependencies
focal_class.modifier: private final
focal_class.original_string: private final Set<String> dependencies;
focal_class.type: Set<String>
focal_class.var_name: dependencies
focal_class.file: runtime-management/runtime-management-impl/src/main/java/io/cloudslang/runtime/impl/python/PythonExecutor.java
focal_class.identifier: PythonExecutor
focal_class.interfaces: implements Executor
focal_class.class_method_signature: PythonExecutor.PythonExecutor()
focal_class.full_signature: public  PythonExecutor()
focal_class.identifier: PythonExecutor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  PythonExecutor()
focal_class.class_method_signature: PythonExecutor.PythonExecutor(Set<String> dependencies)
focal_class.full_signature: public  PythonExecutor(Set<String> dependencies)
focal_class.identifier: PythonExecutor
focal_class.modifiers: public
focal_class.parameters: (Set<String> dependencies)
focal_class.signature:  PythonExecutor(Set<String> dependencies)
focal_class.class_method_signature: PythonExecutor.initInterpreter(Set<String> dependencies)
focal_class.full_signature: protected PythonInterpreter initInterpreter(Set<String> dependencies)
focal_class.identifier: initInterpreter
focal_class.modifiers: protected
focal_class.parameters: (Set<String> dependencies)
focal_class.return: PythonInterpreter
focal_class.signature: PythonInterpreter initInterpreter(Set<String> dependencies)
focal_class.class_method_signature: PythonExecutor.exec(String script, Map<String, Serializable> callArguments)
focal_class.full_signature: public PythonExecutionResult exec(String script, Map<String, Serializable> callArguments)
focal_class.identifier: exec
focal_class.modifiers: public
focal_class.parameters: (String script, Map<String, Serializable> callArguments)
focal_class.return: PythonExecutionResult
focal_class.signature: PythonExecutionResult exec(String script, Map<String, Serializable> callArguments)
focal_class.class_method_signature: PythonExecutor.isThreadsRelatedModuleIssue(Exception e)
focal_class.full_signature: private boolean isThreadsRelatedModuleIssue(Exception e)
focal_class.identifier: isThreadsRelatedModuleIssue
focal_class.modifiers: private
focal_class.parameters: (Exception e)
focal_class.return: boolean
focal_class.signature: boolean isThreadsRelatedModuleIssue(Exception e)
focal_class.class_method_signature: PythonExecutor.exec(String script)
focal_class.full_signature: private PythonExecutionResult exec(String script)
focal_class.identifier: exec
focal_class.modifiers: private
focal_class.parameters: (String script)
focal_class.return: PythonExecutionResult
focal_class.signature: PythonExecutionResult exec(String script)
focal_class.class_method_signature: PythonExecutor.getPythonLocals()
focal_class.full_signature: private Map<String, Serializable> getPythonLocals()
focal_class.identifier: getPythonLocals
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Map<String, Serializable>
focal_class.signature: Map<String, Serializable> getPythonLocals()
focal_class.class_method_signature: PythonExecutor.eval(String prepareEnvironmentScript, String expr, Map<String, Serializable> context)
focal_class.full_signature: public PythonEvaluationResult eval(String prepareEnvironmentScript, String expr, Map<String, Serializable> context)
focal_class.identifier: eval
focal_class.modifiers: public
focal_class.parameters: (String prepareEnvironmentScript, String expr, Map<String, Serializable> context)
focal_class.return: PythonEvaluationResult
focal_class.signature: PythonEvaluationResult eval(String prepareEnvironmentScript, String expr, Map<String, Serializable> context)
focal_class.class_method_signature: PythonExecutor.getTruncatedExpression(String expr)
focal_class.full_signature: private String getTruncatedExpression(String expr)
focal_class.identifier: getTruncatedExpression
focal_class.modifiers: private
focal_class.parameters: (String expr)
focal_class.return: String
focal_class.signature: String getTruncatedExpression(String expr)
focal_class.class_method_signature: PythonExecutor.handleExceptionSpecialCases(String message)
focal_class.full_signature: private String handleExceptionSpecialCases(String message)
focal_class.identifier: handleExceptionSpecialCases
focal_class.modifiers: private
focal_class.parameters: (String message)
focal_class.return: String
focal_class.signature: String handleExceptionSpecialCases(String message)
focal_class.class_method_signature: PythonExecutor.checkValidInterpreter()
focal_class.full_signature: private void checkValidInterpreter()
focal_class.identifier: checkValidInterpreter
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void checkValidInterpreter()
focal_class.class_method_signature: PythonExecutor.eval(String prepareEnvironmentScript, String script)
focal_class.full_signature: protected Serializable eval(String prepareEnvironmentScript, String script)
focal_class.identifier: eval
focal_class.modifiers: protected
focal_class.parameters: (String prepareEnvironmentScript, String script)
focal_class.return: Serializable
focal_class.signature: Serializable eval(String prepareEnvironmentScript, String script)
focal_class.class_method_signature: PythonExecutor.allocate()
focal_class.full_signature: @Override public void allocate()
focal_class.identifier: allocate
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void allocate()
focal_class.class_method_signature: PythonExecutor.release()
focal_class.full_signature: @Override public void release()
focal_class.identifier: release
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void release()
focal_class.class_method_signature: PythonExecutor.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: PythonExecutor.isClosed()
focal_class.full_signature: public boolean isClosed()
focal_class.identifier: isClosed
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isClosed()
focal_class.class_method_signature: PythonExecutor.initInterpreter()
focal_class.full_signature: private void initInterpreter()
focal_class.identifier: initInterpreter
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void initInterpreter()
focal_class.class_method_signature: PythonExecutor.prepareInterpreterContext(Map<String, Serializable> context)
focal_class.full_signature: private void prepareInterpreterContext(Map<String, Serializable> context)
focal_class.identifier: prepareInterpreterContext
focal_class.modifiers: private
focal_class.parameters: (Map<String, Serializable> context)
focal_class.return: void
focal_class.signature: void prepareInterpreterContext(Map<String, Serializable> context)
focal_class.class_method_signature: PythonExecutor.resolveJythonObjectToJavaExec(PyObject value, String key)
focal_class.full_signature: private Serializable resolveJythonObjectToJavaExec(PyObject value, String key)
focal_class.identifier: resolveJythonObjectToJavaExec
focal_class.modifiers: private
focal_class.parameters: (PyObject value, String key)
focal_class.return: Serializable
focal_class.signature: Serializable resolveJythonObjectToJavaExec(PyObject value, String key)
focal_class.class_method_signature: PythonExecutor.resolveJythonObjectToJavaEval(PyObject value, String expression)
focal_class.full_signature: private Serializable resolveJythonObjectToJavaEval(PyObject value, String expression)
focal_class.identifier: resolveJythonObjectToJavaEval
focal_class.modifiers: private
focal_class.parameters: (PyObject value, String expression)
focal_class.return: Serializable
focal_class.signature: Serializable resolveJythonObjectToJavaEval(PyObject value, String expression)
focal_class.class_method_signature: PythonExecutor.resolveJythonObjectToJava(PyObject value, String errorMessage)
focal_class.full_signature: private Serializable resolveJythonObjectToJava(PyObject value, String errorMessage)
focal_class.identifier: resolveJythonObjectToJava
focal_class.modifiers: private
focal_class.parameters: (PyObject value, String errorMessage)
focal_class.return: Serializable
focal_class.signature: Serializable resolveJythonObjectToJava(PyObject value, String errorMessage)
focal_class.class_method_signature: PythonExecutor.keyIsExcluded(String key, PyObject value)
focal_class.full_signature: private boolean keyIsExcluded(String key, PyObject value)
focal_class.identifier: keyIsExcluded
focal_class.modifiers: private
focal_class.parameters: (String key, PyObject value)
focal_class.return: boolean
focal_class.signature: boolean keyIsExcluded(String key, PyObject value)
focal_method.body: public PythonExecutionResult exec(String script, Map<String, Serializable> callArguments) {
          checkValidInterpreter();
          initInterpreter();
          prepareInterpreterContext(callArguments);
  
          Exception originException = null;
          for(int i = 0; i < RETRIES_NUMBER_ON_THREADED_ISSUE; i++) {
              try {
                  return exec(script);
              } catch (Exception e) {
                  if(!isThreadsRelatedModuleIssue(e)) {
                      throw new RuntimeException("Error executing python script: " + e, e);
                  }
                  if(originException == null) {
                      originException = e;
                  }
              }
          }
          throw new RuntimeException("Error executing python script: " + originException, originException);
      }
focal_method.class_method_signature: PythonExecutor.exec(String script, Map<String, Serializable> callArguments)
focal_method.full_signature: public PythonExecutionResult exec(String script, Map<String, Serializable> callArguments)
focal_method.identifier: exec
focal_method.invocations: checkValidInterpreter initInterpreter prepareInterpreterContext exec isThreadsRelatedModuleIssue
focal_method.modifiers: public
focal_method.parameters: (String script, Map<String, Serializable> callArguments)
focal_method.return: PythonExecutionResult
focal_method.signature: PythonExecutionResult exec(String script, Map<String, Serializable> callArguments)