Package org.python.core

Examples of org.python.core.ThreadState


        }
        super.__delitem__(key);
    }

    public PyObject __call__(PyObject args[], String keywords[]) {
        ThreadState ts = Py.getThreadState();
        if (ts.recursion_depth++ > ts.systemState.getrecursionlimit())
            throw Py.RuntimeError("maximum __call__ recursion depth exceeded");
        try {
            PyType self_type = getType();
            PyObject impl = self_type.lookup("__call__");
View Full Code Here


        }
        super.__delitem__(key);
    }

    public PyObject __call__(PyObject args[], String keywords[]) {
        ThreadState ts = Py.getThreadState();
        if (ts.recursion_depth++ > ts.systemState.getrecursionlimit())
            throw Py.RuntimeError("maximum __call__ recursion depth exceeded");
        try {
            PyType self_type = getType();
            PyObject impl = self_type.lookup("__call__");
View Full Code Here

        return deque_toString();
    }

    @ExposedMethod(names = "__repr__")
    final String deque_toString() {
        ThreadState ts = Py.getThreadState();
        if (!ts.enterRepr(this)) {
            return "[...]";
        }
        StringBuilder buf = new StringBuilder("deque").append("([");
        for (Node tmp = header.right; tmp != header; tmp = tmp.right) {
            buf.append(tmp.data.__repr__().toString());
            if (tmp.right != header) {
                buf.append(", ");
            }
        }
        buf.append("])");
        ts.exitRepr(this);
        return buf.toString();
    }
View Full Code Here

        assertEquals(3, bound.__call__(Py.newString("nothello"), Py.One).asInt());
    }

    public void testThreadState() throws Exception {
        PyBuiltinCallable bound = createBound("needsThreadState", STRING, THREAD_STATE, STRING);
        ThreadState ts = Py.getThreadState();
        PyObject expected = Py.newString("foo got state " + ts.hashCode());
        assertEquals(expected, bound.__call__(Py.getThreadState(), Py.newString("foo")));
        assertEquals(expected, bound.__call__(Py.newString("foo")));
        ts = new ThreadState(new Thread(), ts.systemState);
        assertEquals(Py.newString("foo got state " + ts.hashCode()),
                     bound.__call__(ts, Py.newString("foo")));
    }
View Full Code Here

                                                        "simpleexposed",
                                                        new String[0],
                                                        new String[] {"null"},
                                                        "");
        PyBuiltinCallable bound = createBound(exp);
        ThreadState ts = Py.getThreadState();
        PyObject arg0 = Py.newString("bar");
        PyObject arg1 = Py.newString(" and extra");
        PyObject expected = Py.newString("bar got state " + ts.hashCode() + " got type and extra");
        assertEquals(expected, bound.__call__(Py.getThreadState(), arg0, arg1));
        assertEquals(expected, bound.__call__(arg0, arg1));
    }
View Full Code Here

    javaThread=Thread.currentThread();
  }
 
  protected void interruptViaPython() {

    ThreadState ts=pythonThread;
    TraceFunction breaker=new BreakTraceFunction();
        TraceFunction oldTrace = ts.tracefunc;
        ts.tracefunc = breaker;
        if (ts.frame != null)
            ts.frame.tracefunc = breaker;
View Full Code Here

TOP

Related Classes of org.python.core.ThreadState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.