<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Hussain,<br>
<br>
have you upgraded to the latest Stackless version?<br>
I think the necessary changes have been incorporated, lately.<br>
<br>
This function should not be visible from Python. It is just<br>
a change that makes sys._getframe behave correctly.<br>
<br>
cheers - chris<br>
<br>
On 10/10/11 3:55 PM, Hussain Bohra wrote:
<blockquote
cite="mid:1318254900.9865.YahooMailNeo@web114713.mail.gq1.yahoo.com"
type="cite">
<div style="color:#000; background-color:#fff; font-family:Courier
New, courier, monaco, monospace, sans-serif;font-size:10pt">
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2">Hi Christian,</font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><br>
</font></span></div>
<div><font class="Apple-style-span" face="arial, helvetica,
sans-serif" size="2"><span>I have incorporated the following
changes in the </span>file<b> stackless_util.c</b>:</font></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i><br>
</i></font></span></div>
<blockquote class="webkit-indent-blockquote"
style="border-top-style: none; border-right-style: none;
border-bottom-style: none; border-left-style: none;
border-width: initial; border-color: initial; padding-top:
0px; padding-right: 0px; padding-bottom: 0px; padding-left:
0px; ">
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i>static PyObject *</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i>tasklet_get_frame(PyTaskletObject
*task)</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i>{</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> PyFrameObject *f
= (PyFrameObject *) slp_get_frame(task);</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> PyObject *ret;</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i><br>
</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> while (f != NULL
&& !PyFrame_Check(f)) {</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> f =
f->f_back;</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> }</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> ret = (PyObject
*) f;</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i><br>
</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> if (ret == NULL)
ret = Py_None;</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> Py_INCREF(ret);</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i> return ret;</i></font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><i>}</i></font></span></div>
</blockquote>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><br>
</font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2">I am able to build the
stackless-python without any errors.</font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2">But after which I am not
able to use this method from the python prompt, I am not
sure whether I need to write any specific code to expose
this new method?</font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2"><br>
</font></span></div>
<div><span><font class="Apple-style-span" face="arial,
helvetica, sans-serif" size="2">Can you please let me know
your feedback.</font></span></div>
<div><font class="Apple-style-span" face="arial, helvetica,
sans-serif" size="2"><br>
</font></div>
<div><font class="Apple-style-span" face="arial, helvetica,
sans-serif" size="2">Thanks in advance.</font></div>
<div><font class="Apple-style-span" face="arial, helvetica,
sans-serif" size="2">Hussain Bohra</font></div>
<div style="font-family: 'Courier New', courier, monaco,
monospace, sans-serif; font-size: 10pt; "><br>
</div>
<div style="font-size: 10pt; font-family: 'Courier New',
courier, monaco, monospace, sans-serif; ">
<div style="font-size: 12pt; font-family: 'times new roman',
'new york', times, serif; "><font face="Arial" size="2">
<hr size="1"><b><span style="font-weight:bold;">From:</span></b>
Hussain Bohra <a class="moz-txt-link-rfc2396E" href="mailto:hussainbohra_30@yahoo.com"><hussainbohra_30@yahoo.com></a><br>
<b><span style="font-weight: bold;">To:</span></b>
<a class="moz-txt-link-rfc2396E" href="mailto:stackless@stackless.com">"stackless@stackless.com"</a> <a class="moz-txt-link-rfc2396E" href="mailto:stackless@stackless.com"><stackless@stackless.com></a><br>
<b><span style="font-weight: bold;">Sent:</span></b>
Thursday, 11 August 2011 3:23 PM<br>
<b><span style="font-weight: bold;">Subject:</span></b>
Re: How do I get a callstack of a Tasklet ?<br>
</font><br>
<div id="yiv675152500">
<div>
<div style="color: rgb(0, 0, 0); background-color:
rgb(255, 255, 255); font-size: 10pt; font-family:
arial, helvetica, sans-serif; ">
<div><span>Hi Christian,</span></div>
<div><span><br>
</span></div>
<div><span>Thanks for this solution.</span></div>
<div><span>I will incorporate changes suggested by you
and will let you know the updates.</span></div>
<div> </div>
<div style="color: rgb(0, 0, 0); text-align: left;
font-family: 'monotype corsiva'; "
id="yiv675152500RTEContent">
<div style="color: rgb(0, 0, 255); font-family:
'times new roman'; "><font size="3">Thanks and
Regards,<br>
Hussain Bohra<br>
</font></div>
</div>
<div><br>
</div>
<div style="font-size: 10pt; font-family: arial,
helvetica, sans-serif; ">
<div style="font-size: 12pt; font-family: times,
serif; "><font face="Arial" size="2">
<hr size="1"><b><span style="font-weight:bold;">From:</span></b>
<a class="moz-txt-link-rfc2396E" href="mailto:stackless-request@stackless.com">"stackless-request@stackless.com"</a>
<a class="moz-txt-link-rfc2396E" href="mailto:stackless-request@stackless.com"><stackless-request@stackless.com></a><br>
<b><span style="font-weight:bold;">To:</span></b>
<a class="moz-txt-link-abbreviated" href="mailto:stackless@stackless.com">stackless@stackless.com</a><br>
<b><span style="font-weight:bold;">Sent:</span></b>
Wednesday, 10 August 2011 3:30 PM<br>
<b><span style="font-weight:bold;">Subject:</span></b>
Stackless Digest, Vol 91, Issue 5<br>
</font><br>
Send Stackless mailing list submissions to<br>
<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:stackless@stackless.com"
target="_blank"
href="mailto:stackless@stackless.com">stackless@stackless.com</a><br>
<br>
To subscribe or unsubscribe via the World Wide
Web, visit<br>
<a moz-do-not-send="true" rel="nofollow"
target="_blank"
href="http://www.stackless.com/mailman/listinfo/stackless">http://www.stackless.com/mailman/listinfo/stackless</a><br>
or, via email, send a message with subject or body
'help' to<br>
<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:stackless-request@stackless.com"
target="_blank"
href="mailto:stackless-request@stackless.com">stackless-request@stackless.com</a><br>
<br>
You can reach the person managing the list at<br>
<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:stackless-owner@stackless.com"
target="_blank"
href="mailto:stackless-owner@stackless.com">stackless-owner@stackless.com</a><br>
<br>
When replying, please edit your Subject line so it
is more specific<br>
than "Re: Contents of Stackless digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. pickling bug (was: Stackless Digest, Vol
90, Issue 3)<br>
(Christian Tismer)<br>
2. About submissions to this list (Christian
Tismer)<br>
3. Re: About submissions to this list (Rob
Coops)<br>
4. Re: About submissions to this list (Richard
Tew)<br>
5. Re: About submissions to this list (Christian
Tismer)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Tue, 09 Aug 2011 16:06:05 +0200<br>
From: Christian Tismer <<a
moz-do-not-send="true" rel="nofollow"
ymailto="mailto:tismer@stackless.com"
target="_blank"
href="mailto:tismer@stackless.com">tismer@stackless.com</a>><br>
To: The Stackless Python Mailing List <<a
moz-do-not-send="true" rel="nofollow"
ymailto="mailto:stackless@stackless.com"
target="_blank"
href="mailto:stackless@stackless.com">stackless@stackless.com</a>><br>
Cc: Kristj?n Valur J?nsson <<a
moz-do-not-send="true" rel="nofollow"
ymailto="mailto:kristjan@ccpgames.com"
target="_blank"
href="mailto:kristjan@ccpgames.com">kristjan@ccpgames.com</a>>,
Richard Tew<br>
<<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:richard.m.tew@gmail.com"
target="_blank"
href="mailto:richard.m.tew@gmail.com">richard.m.tew@gmail.com</a>><br>
Subject: [Stackless] pickling bug (was:
Stackless Digest, Vol 90,<br>
Issue 3)<br>
Message-ID: <<a moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:4E413ECD.5050709@stackless.com"
target="_blank"
href="mailto:4E413ECD.5050709@stackless.com">4E413ECD.5050709@stackless.com</a>><br>
Content-Type: text/plain; charset=ISO-8859-1;
format=flowed<br>
<br>
Hi,<br>
<br>
I sent this almost-patch a while ago, but it was
probably invisible,<br>
due to a bad subject line. Here it is again:<br>
<br>
file stackless_util.c:<br>
<br>
static PyObject *<br>
tasklet_get_frame(PyTaskletObject *task)<br>
{<br>
PyFrameObject *f = (PyFrameObject *)
slp_get_frame(task);<br>
PyObject *ret;<br>
<br>
while (f != NULL && !PyFrame_Check(f))
{<br>
f = f->f_back;<br>
}<br>
ret = (PyObject *) f;<br>
<br>
if (ret == NULL) ret = Py_None;<br>
Py_INCREF(ret);<br>
return ret;<br>
}<br>
<br>
This should resolve the problem.<br>
<br>
ciao - chris<br>
<br>
On 7/8/11 2:26 PM, Christian Tismer wrote:<br>
> On 7/8/11 1:34 PM, Christian Tismer wrote:<br>
>> On 7/8/11 1:53 AM, Richard Tew wrote:<br>
>>> On Thu, Jul 7, 2011 at 10:10 PM,
Hussain Bohra<br>
>>> <<a moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:hussainbohra_30@yahoo.com"
target="_blank"
href="mailto:hussainbohra_30@yahoo.com">hussainbohra_30@yahoo.com</a>>
wrote:<br>
>>>> Hi Christian,<br>
>>>><br>
>>>> Thanks for your feedback.<br>
>>>><br>
>>>> Could you kindly let us know when
you are done with the changes, so <br>
>>>> that we<br>
>>>> can complete the existing tasks
that are dependent on this fix.<br>
>>> Can't you work around it? Like check
if a frame is a cframe and skip<br>
>>> it, if it is the case? I haven't
looked at the traceback generation<br>
>>> in detail, but I imagine that
something along the following lines<br>
>>> would work..<br>
>>><br>
>>> lastTasklet = stackless.current<br>
>>> thisTasklet = lastTasklet.next<br>
>>> while True:<br>
>>> thisFrame = thisTasklet.frame<br>
>>> while thisFrame is not None:<br>
>>> if not isinstance(thisFrame,
stackless.cframe):<br>
>>> # Do traceback related
stuff.<br>
>>> thisFrame = thisFrame.f_back<br>
>>> thisTasklet = thisTasklet.next<br>
>>> if lastTasklet is thisTasklet:<br>
>>> break<br>
>><br>
>> Hi Richard, Hussain,<br>
>><br>
>> yes, I had a look now, and you are right.
CFrames get into the way,<br>
>> but are a small problem. Your workaround
should be a simple quick<br>
>> solution in the first place, and I
encourage Hussain to try that first.<br>
>> It is a really simple patch to
traceback.py: insert a check into <br>
>> extract_stack<br>
>> before "if limit is None:":<br>
>><br>
>> while f and not isinstance(f,
types.FrameType):<br>
>> f = f.f_back<br>
>><br>
>> That should do.<br>
>><br>
>>
---------------------------------------------<br>
>> Now to the omission in stackless:<br>
>> The special treatment of cframes is quite
limited in stackless:<br>
>><br>
>> - sys._getframe has a patch to skip over
anything that is no normal <br>
>> frame.<br>
>> - frame objects have a getter function
frame_getback() instead of the <br>
>> f_back<br>
>> field.<br>
>><br>
>> The only way how the treatment of cframes
might be circumvented<br>
>> in extract_stack is when a cframe is
given as an argument, and that<br>
>> was the omission in stackless:<br>
>> tasklet.frame exposes whatever it has to
the user. Only for the running<br>
>> tasklet, this gets redirected to the
threadstate's frame, which in the<br>
>> from python visible context never is a
cframe.<br>
>><br>
>> The function slp_get_frame is the culprit
(stackless_util.c):<br>
>><br>
>> /* CAUTION: This function returns a
borrowed reference */<br>
>> PyFrameObject *<br>
>> slp_get_frame(PyTaskletObject *task)<br>
>> {<br>
>> PyThreadState *ts =
PyThreadState_GET();<br>
>><br>
>> return ts->st.current == task ?
ts->frame : task->f.frame;<br>
>> }<br>
>><br>
>> This is correct for builtin API
functions, but not for the python<br>
>> interface. The getter methon
tasklet_get_frame (taskletobject.c)<br>
>> should skip over cframes.<br>
>><br>
>> static PyObject *<br>
>> tasklet_get_frame(PyTaskletObject *task)<br>
>> {<br>
>> PyObject *ret = (PyObject*)
slp_get_frame(task);<br>
>><br>
>> if (ret == NULL) ret = Py_None;<br>
>> Py_INCREF(ret);<br>
>> return ret;<br>
>> }<br>
>><br>
>> I think something like the following
should do it:<br>
>><br>
>> static PyObject *<br>
>> tasklet_get_frame(PyTaskletObject *task)<br>
>> {<br>
>> PyFrameObject *f = (PyFrameObject *)
slp_get_frame(task);<br>
>> PyObject *ret;<br>
>><br>
>> while (f != NULL &&
!PyFrame_Check(f)) {<br>
>> f = f_fback;<br>
>> }<br>
>> ret = (PyObject *) f;<br>
>><br>
>> if (ret == NULL) ret = Py_None;<br>
>> Py_INCREF(ret);<br>
>> return ret;<br>
>> }<br>
>><br>
>><br>
>> Not yet tested, but I guess that should
do it.<br>
>> Do you want to try when removing
tasklet_become, or should I?<br>
>><br>
>> cheers -- chris<br>
>><br>
><br>
> Correction:<br>
> f = f_fback;<br>
> should be<br>
> f = f->f_back;<br>
><br>
> And as a remark:<br>
> The long-term solution to such problems is to
get rid of these old <br>
> tricks,<br>
> minimizing the patches to cpython as much as
possible.<br>
> We should remove all additions/changes to
frames and replace<br>
> cframes by helper structures that are
associated with a frame<br>
> invisibly and indirectly through a
dictionary.<br>
> Of course a bit tedious, because frames do
not support weak references<br>
> (<a moz-do-not-send="true" rel="nofollow"
target="_blank"
href="http://docs.python.org/library/weakref.html">http://docs.python.org/library/weakref.html</a>).<br>
> I'm thinking of a shadow stack of thunks as
an execution context<br>
> which references the frames, but is used
instead of the frame stack.<br>
><br>
> Maybe it's time for another stackless sprint,
to start a major <br>
> clean-up? :-)<br>
><br>
> cheers - chris<br>
><br>
<br>
<br>
-- <br>
Christian Tismer :^)<mailto:<a
moz-do-not-send="true" rel="nofollow"
ymailto="mailto:tismer@stackless.com"
target="_blank"
href="mailto:tismer@stackless.com">tismer@stackless.com</a>><br>
tismerysoft GmbH : Have a break!
Take a ride on Python's<br>
Johannes-Niemeyer-Weg 9A : *Starship* <a
moz-do-not-send="true" rel="nofollow"
target="_blank"
href="http://starship.python.net/">http://starship.python.net/</a><br>
14109 Berlin : PGP key -> <a
moz-do-not-send="true" rel="nofollow"
target="_blank" href="http://wwwkeys.pgp.net/">http://wwwkeys.pgp.net/</a><br>
work +49 30 802 86 56 mobile +49 173 24 18 776
fax +49 30 80 90 57 05<br>
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B
C09C 5A3B 57F3 BF04<br>
whom do you want to sponsor today? <a
moz-do-not-send="true" rel="nofollow"
target="_blank" href="http://www.stackless.com/">http://www.stackless.com/</a><br>
<br>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Stackless mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Stackless@stackless.com">Stackless@stackless.com</a>
<a class="moz-txt-link-freetext" href="http://www.stackless.com/mailman/listinfo/stackless">http://www.stackless.com/mailman/listinfo/stackless</a></pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Christian Tismer :^) <a class="moz-txt-link-rfc2396E" href="mailto:tismer@stackless.com"><mailto:tismer@stackless.com></a>
tismerysoft GmbH : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 : *Starship* <a class="moz-txt-link-freetext" href="http://starship.python.net/">http://starship.python.net/</a>
14482 Potsdam : PGP key -> <a class="moz-txt-link-freetext" href="http://pgp.uni-mainz.de">http://pgp.uni-mainz.de</a>
work +49 173 24 18 776 mobile +49 173 24 18 776 fax n.a.
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? <a class="moz-txt-link-freetext" href="http://www.stackless.com/">http://www.stackless.com/</a></pre>
</body>
</html>