[Stackless] Question abut slprofile.py

Andrew Francis andrewfr_ice at yahoo.com
Fri Dec 19 21:25:29 CET 2008

Hi Kristjan and folks:

Once again thanks for the help. And thanks for the explanation. However I am still having trouble. I removed the import blue, line 22, and line 20 (the Timer than makes a reference later to blue.os()).

here is a code fragment:

if __name__  == "__main__":
   profiler = Profile()

/home/user> python profiled.py 1 100
Traceback (most recent call last):
  File "profiled.py", line 63, in <module>
  File "/usr/local/lib/python2.5/profile.py", line 456, in run
    return self.runctx(cmd, dict, dict)
  File "/home/user/slprofile.py", line 51, in runctx
    profile.Profile.runctx(self, cmd, globals, locals)
  File "/usr/local/lib/python2.5/profile.py", line 460, in runctx
AttributeError: Profile instance has no attribute 'dispatcher'

I have included a sample programme. Eventually I want to run slprofile inside a server. I would greatly appreciate it if you can show me how to properly use slprofile.py


--- On Fri, 12/19/08, Kristján Valur Jónsson <kristjan at ccpgames.com> wrote:

> From: Kristján Valur Jónsson <kristjan at ccpgames.com>
> Subject: RE: [Stackless] Question abut slprofile.py
> To: "Kristján Valur Jónsson" <kristjan at ccpgames.com>, "andrewfr_ice at yahoo.com" <andrewfr_ice at yahoo.com>, "stackless at stackless.com" <stackless at stackless.com>
> Date: Friday, December 19, 2008, 6:52 AM
> Blue is a module that is part of the eve engine.
> It is used in this module solely to provide a timer. Just
> remove it, and line 22, and then you are all set.
> Stackless has, since python 2.3, I think, a special
> "per tasklet" trace flag.  That is, stackless
> saves and restores the trace flag in the python trhread
> state for each tasklet.  This is an attempt, I think, at
> making profiling (and tracing) sensible, by focusing on a
> single tasklet only.
> It is not very useful for us, however. 
> We want to have a running application, and then, just turn
> on profiling (using slprofile.Profile.start()) and stop it
> using slprofile.Profile.stop(), ans see what the app has
> been upto in the meantime.
> In order to do this, we had to disable the per-tasklet
> saving feature of stackless.
> I attach the three files that have the relevant
> modifications, for stackless 2.5
> Good luck,
> Kristján
> -----Original Message-----
> From: stackless-bounces at stackless.com
> [mailto:stackless-bounces at stackless.com] On Behalf Of
> Kristján Valur Jónsson
> Sent: 18. desember 2008 09:11
> To: andrewfr_ice at yahoo.com; stackless at stackless.com
> Subject: Re: [Stackless] Question abut slprofile.py
> Attached.
> Note that what we also used is a custom flag in stackless,
> "globaltrace" which makes the tracing state of
> python global (for the thread) instead of being maintained
> for each tasklet.
> Not only does it allow us to take a profiling
> "snapshot" of a running application, it also
> prevented crashes in stackless, which was crashing horribly
> if any exceptions were being raised in the trace callbacks.
> Actually, the last issue was fixed by us changing slprofile
> to not rely on the stackless tasklet switching callbacks,
> which tend to have weird behaviour, but rather just querying
> for the current tasklet in the trace functions.
> If you want, I can provide you with the changed files to
> the the "globaltrace" functionality, but it is a
> little more work.
> K
> -----Original Message-----
> From: stackless-bounces at stackless.com
> [mailto:stackless-bounces at stackless.com] On Behalf Of Andrew
> Francis
> Sent: 17. desember 2008 22:17
> To: stackless at stackless.com
> Subject: [Stackless] Question abut slprofile.py
> Hi Folks:
> A while ago, I recall a thread about using a modified
> profile module, slprofile for use with Stackless. Where can
> I find slprofile.py and its documentation?
> Thanks,
> Andrew
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless

-------------- next part --------------
A non-text attachment was scrubbed...
Name: profiled.py
Type: text/x-python
Size: 1523 bytes
Desc: not available
URL: <http://www.stackless.com/pipermail/stackless/attachments/20081219/e3c8644a/attachment.py>

More information about the Stackless mailing list