Web Spider

Peter Hansen peter at engcorp.com
Tue Jul 6 17:19:01 CEST 2004

Thomas Lindgaard wrote:

> A couple of questions:
> 1) Why use the 
>   if __name__ == '__main__':
> construct?

Answered indirectly in this FAQ: 

> 2) In Retrievepool.__init__ the Retriever.__init__ is called with
> self.inputQueue and self.outputQueue as arguments. Does this mean that
> each Retriever thread has a reference to Retrievepool.inputQueue and
> Retrievepool.outputQueue 

Yes, and that's sort of the whole point of the thing.

> 3) How many threads will be running? Spider.run initializes the
> Retrievepool and this will consist of MAX_THREADS threads, so once the
> crawler is running there will be the main thread (caught in the while loop
> in Spider.run) and MAX_THREADS Retriever threads running, right?

Yep.  Good analysis. :-)  You could inject this somewhere to

print len(threading.enumerate()), 'threads exist'


More information about the Python-list mailing list