[Stackless] Question abut slprofile.py

Esteban U. Caamano Castro euccastro at yahoo.com
Fri Dec 19 16:33:41 CET 2008


You may want to remove that "import log" while you're at it. It's not used.



----- Mensagem original ----
De: Esteban U. Caamano Castro <euccastro at yahoo.com>
Para: stackless at stackless.com
Enviadas: Sexta-feira, 19 de Dezembro de 2008 16:30:27
Assunto: Re: Question abut slprofile.py

> Thanks for the information and slprofile.py. However when I run a programme using slprofile.py, I get:
>
> No module named blue. 
>
> Where do I get blue from?

You don't; it's a CCP thing. Fortunately, you can do without it.


AFAICT, Blue is only used in the Timer class.

class Timer(object):
    #This class creates a seconds timer initialized to zero on creation, using the hypersensitive bluetimer if possible.
    def __init__(self):
        self.startTime = blue.os.GetTime(1)

    def __call__(self):
        return float(blue.os.GetTime(1) - self.startTime) *1e-7

In turn, this blue-based Timer is only used as a different default for the profiler. 

class Profile(profile.Profile):
    base = profile.Profile
    def __init__(self, timer = None, bias=None):
        self.current_tasklet = stackless.getcurrent()
        self.thread_id = thread.get_ident()
        if timer is None: timer = Timer()     # <<<<<<<<<<<<<<<<<<<<
        self.base.__init__(self, timer, bias)
        self.sleeping = {}


If you
- comment out the line that refers to Timer in Profile.__init__,
- delete class Timer altogether, and
- remove the import of blue
then everything should work fine. You'll get the standard profile precision by default instead of the "hypersensitive" one that blue.os.GetTime() promises, but if you figure out other way to get a more precise timer you can still feed that to Profile on initialization.

HTH,




More information about the Stackless mailing list