[PEAK] Lazy import loops (was Re: peak.running.logs in .ini files)

Phillip J. Eby pje at telecommunity.com
Tue Aug 17 16:03:04 EDT 2004

At 09:44 AM 8/3/04 -0400, Phillip J. Eby wrote:
>At 11:05 AM 8/3/04 +0200, Radek Kanovsky wrote:
>>It relates to 'logs' appearance in .ini files and probably to its laziness.
>>There are at least two solutions how to bypass this error:
>>1. Reload lazy peak.running module before accessing lazy logs
>>    from any .ini file (by uncommenting dir(running) in example)
>>2. Redefine peak.logs.* property in .ini file, so definition doesn't rely
>>    on lazy logs.
>>    [peak.logs]
>>    * = importString("peak.running.logs.LogStream")(
>>                     stream=sys.stderr, levelName='WARNING'
>>        )
>I'll take a look at this and see what I can find out.

Well, it's a lot more complicated than even I thought it would be.  It 
turns out that there was another tricky race condition of sorts in 
'peak.util.imports'.  Specifically, if a lazily-loaded module has no 
post-import hooks registered, then attempting to register a hook will cause 
the hook to be run immediately, even if the module hasn't actually been 
loaded yet.

I've now fixed this in CVS.  Sorry it took so long to track it down; I've 
had little time for actual PEAK coding recently.

More information about the PEAK mailing list