[Grok-dev] Context Constantly Reinitializing/Switching?

Brandon Craig Rhodes brandon at rhodesmill.org
Sun Jun 22 22:52:06 EDT 2008


Kenneth Miller <xkenneth at gmail.com> writes:

...
> <buildoutbuilder.grokapp.app.BuildoutBuilder object at 0x25a98b0>
> <buildoutbuilder.grokapp.app.BuildoutBuilder object at 0x20d1870>
> <buildoutbuilder.grokapp.app.BuildoutBuilder object at 0x20d1870>
> <buildoutbuilder.grokapp.app.BuildoutBuilder object at 0x20d1870>
> <buildoutbuilder.grokapp.app.BuildoutBuilder object at 0x20d1870>
> <buildoutbuilder.grokapp.app.BuildoutBuilder object at 0x25a98b0>
>
> The context object is always of the same type, but sometimes it's
> different objects. It's not reinitializing my app each time, because
> the objects aren't random, but it seems to switch between a few. Any
> ideas?

Maybe it is, indeed, a completely different object each time, that just
happens to get allocated in the same place over and over several times
in a row because of how malloc() works, then goes somewhere else when
the runtime allocates an object that gets in the way of its using the
same place.

Try:

    class BuildoutBuilder(...):
        def __init__(...):
            self.c = 0

        def __str__(self):
            self.c += 1
            return '<BuildoutBuilder %x with counter %d>' % (self.id, self.c)

so that you can tell how many times you've printed each object.  If all
the counts are 0, you're seeing a new object each time, even if it gets
the same address as a previous object.  If the count increases, then
you're seeing the same object several times.

-- 
Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon


More information about the Grok-dev mailing list