On Jun 12, 2006, at 6:54 AM, Richard Clark wrote:
>
> Not really sure what's going on here, I'm really scratching my head.
>
> I'm using call_on_startup to fire up a couple of threads, one which
> performs background processing, and another which logs into a jabber
> conference and provides logging services.
>
> The problem is that any function I add to call_on_startup gets called
> twice, and worse, this appears to happen in two independant forks
> because no amount of attempted thread syncronisation allows me to
> detect that it has previously been called.
>
> It's really really spooky, for example, the "offending" code is in
> startup.py:
>
> for item in call_on_startup:
> item()
>
> Looks simple enough, but if I change it to this:
>
> for item in call_on_startup:
> log.info("Thingy starting: %s" % str(item))
> item(random.randint(0,1000))
> log.info("Thingy started: %s" % str(item))
>
> and do this in controllers.py:
>
> turbogears.startup.call_on_startup = [lambda x: log.debug("Foo: %d" %
> x)]
>
> I get the following in the log:
>
> 2006-06-12 16:48:26,202 turbogears.startup INFO Thingy starting:
> <function <lambda> at 0xb7348b8c>
> 2006-06-12 16:48:26,280 dmt.controllers DEBUG Foo: 769
> 2006-06-12 16:48:26,280 dmt.controllers DEBUG Foo: 769
> 2006-06-12 16:48:26,280 turbogears.startup INFO Thingy started:
> <function <lambda> at 0xb7348b8c>
>
> Ie, the logs bracketting the call only get called once, but the lambda
> gets called twice, and with exactly the same random number no less.
>
> I'm gonna keep working on it, gonna try on a few different machines
> and
> see if I see the same behaviour, it's really creepy. But I figured i'd
> put this here in case anyone else has seen the same behaviour or later
> goes searching for it.
Hmmm, interesting.... I've notice similar behaviour but didn't really
dig too much into it as the double-called code didn't cause any
trouble...
Could this be related to TG logging perhaps? I mean, *maybe* the code
is called just once but the message is logged twice... just a guess.
Hope I didn't add much more creepyness into the issue ;)
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---