public PyObject __call__(PyObject[] args, String[] keywords) { // Set the system state to handle callbacks from java threads Py.setSystemState(systemState); for (PyObject callable : callables) { callable.__call__(args, keywords); } return Py.None; }
protected void setSystemState() { Py.setSystemState(getSystemState()); }
Py.setSystemState(engineSys);
private void setPythonPath(SpongeEngine engine) { if (engine != null) { String pythonPath = getEngineOperations().getProperty(PROP_PYTHON_PATH, null); if (pythonPath != null) { PySystemState engineSys = new PySystemState(); List<String> paths = Arrays.asList(StringUtils.split(pythonPath, PROP_PATH_SEPARATOR)); Collections.reverse(paths); for (String pathElement : paths) { engineSys.path.add(0, Py.newString(pathElement)); } Py.setSystemState(engineSys); } } }
public void run() { Py.setSystemState(systemState); try { func.__call__(args); } catch (PyException exc) { if (exc.match(Py.SystemExit) || exc.match(_systemrestart.SystemRestart)) { return; } Py.stderr.println("Unhandled exception in thread started by " + func); Py.printException(exc); } }
/** * Retrieves <code>name</code> from the PyObject in <code>proxy</code> if it's defined in * Python. This is a specialized helper function for internal PyProxy use. */ public static PyObject findPython(PyProxy proxy, String name) { PyObject o = proxy._getPyInstance(); if (o == null) { proxy.__initProxy__(new Object[0]); o = proxy._getPyInstance(); } PyObject ret = o.__findattr__(name); if (ret instanceof PyMethod) { PyMethod meth = ((PyMethod)ret); if (meth.__func__ instanceof PyReflectedFunction) { PyReflectedFunction func = (PyReflectedFunction)meth.__func__; if (func.nargs > 0 && proxy.getClass() == func.argslist[0].declaringClass) { // This function is the default return for the proxy type if the Python instance // hasn't returned something of its own from __findattr__, so do the standard // Java call on this return null; } } } Py.setSystemState(proxy._getPySystemState()); return ret; }
interp.cleanup(); Py.setSystemState(new PySystemState());
Py.setSystemState(Py.defaultSystemState); if (classLoader != null) { Py.defaultSystemState.setClassLoader(classLoader);