[Stackless] Basic stackless embedding
Andrew Macentire
amacentire at ymail.com
Tue Jan 18 17:30:13 CET 2011
I am replying to my own thread.
Doing a PyStackless_GetRunCount() shows that 0 tasklets are running and that explains why the st.current is in that state.However, I'm not sure crashing the whole application is the best way for PyStackless_GetCurrent() to behave.
Also, what contributed to my confusion was that from the PyRun_Simplestring("print stackless.getcurrent()") the return value was 1.I guess I will look further today to see why exactly that is so.
--- On Mon, 17/1/11, Andrew Macentire <amacentire at ymail.com> wrote:
From: Andrew Macentire <amacentire at ymail.com>
Subject: [Stackless] Basic stackless embedding
To: stackless at stackless.com
Date: Monday, 17 January, 2011, 6:18 PM
Hello! I'm new to the field and I was trying a simple stackless embedding test and experienced problems.Here is the short source code to my test:
#include <stackless_api.h>
#include <windows.h>
int main(void)
{
PyInterpreterState* pys;
Py_Initialize();
PyRun_SimpleString("import stackless");
PyRun_SimpleString("print
stackless.runcount");
PyRun_SimpleString("print stackless.getcurrent()");
PyObject *task;
task=PyStackless_GetCurrent(); // <==== CRASH HERE
Py_DECREF(task);
return 1;
}
I am using MSVC 8 and an unmodified distribution of Python 2.7.1 Stackless 3.1b3 060516,
built with the same compiler.
The crash happens inside PyStackless_GetCurrent, which looks like this:
PyObject
*
PyStackless_GetCurrent(void)
{
PyThreadState *ts = PyThreadState_GET();
PyObject *t = (PyObject*)ts->st.current;
Py_INCREF(t);
return t;
}
The crash happens on Py_INCREF(t), because the thread state object returned by PyThreadState_GET
doesn't seem to be properly initialized.
I'm probably missing something very basic, but any help is appreciated.
Cheers!
-----Inline Attachment Follows-----
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20110118/4613fa76/attachment.html>
More information about the Stackless
mailing list