[poky] [PATCH 3/7] bb: add bb.fetcher as dynamic fetch module instance for fetch/fetch2

Yu Ke ke.yu at intel.com
Mon Jan 10 17:16:57 PST 2011


On Jan 11, 00:50, Richard Purdie wrote:
> On Tue, 2011-01-11 at 08:13 +0800, Yu Ke wrote:
> > > If we assume bb.fetch2 will not make calls to bb.fetch we can simplify
> > > this to:
> > > 
> > > if os.environ.get("BBFETCH2"):
> > >     from bb import fetch2 as fetch
> > >     sys.modules['bb.fetch'] = sys.modules['bb.fetch2']
> > 
> > BTW, a quick question. with sys.modules['bb.fetch'] =
> > sys.modules['bb.fetch2'], will the future "import bb.fetch" override
> > the bb.fetch in namespeace ? I assume not, but just want to double
> > confirm. I know that "import <module>" will not be executed if the
> > <module> is already imported. So does python use sys.modules[<module>]
> > to decide if it is already imported?
> 
> This is correct, yes. Python uses sys.modules behind the scenes when it
> sees "import X". You can prove this by placing a sys.exit(1) in the
> bb.fetch code :)

Thanks, yes, it is clear to me now.

Regards
Ke

> 
> 
> 
> _______________________________________________
> poky mailing list
> poky at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/poky



More information about the poky mailing list