How to get existing frames in non-current thread?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Jun 10 18:18:58 EDT 2007


En Sun, 10 Jun 2007 09:17:21 -0300, Fabio Zadrozny <fabiofz at gmail.com>  
escribió:

> On 6/10/07, Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:
>>
>> En Sat, 09 Jun 2007 21:40:40 -0300, Fabio Zadrozny <fabiofz at gmail.com>
>> escribió:
>>
>> > Is there some way to get all the frames for any given thread? -- in a
>> way
>> > that does not require a compiled extension.
>>
>> For the current (calling) thread, you can use sys._getframe()
>> For other threads, you can use sys._current_frames()
>> Frames have a f_back attribute pointing to the previous one, that you  
>> can
>> use to navigate them.
>>
>
> Thanks a lot... I guess I'll have to find another way for versions before
> 2.5 ;-)

The original idea came from  
<http://www.majid.info/mylos/stories/2004/06/10/threadframe.html> but it  
uses a compiled C extension, yes. The code is really small and you should  
not have problems compiling it...

-- 
Gabriel Genellina




More information about the Python-list mailing list