Re: Threading with queues

2009-12-24 Thread Lie Ryan
On 12/24/2009 2:11 PM, Gib Bogle wrote: Lie Ryan wrote: On 12/22/2009 10:47 AM, Gib Bogle wrote: It turns out that this code isn't a great demo of the advantages of threading, on my system anyway. The time taken to execute doesn't vary much when the number of threads is set anywhere from 1 to 6

Re: Threading with queues

2009-12-23 Thread Gib Bogle
Lie Ryan wrote: On 12/22/2009 10:47 AM, Gib Bogle wrote: This is indented over one indentation level too much. You want it to be at the same level as the for above. Here, its at the same level with "t" -- meaning this entire loop gets repeated five times. I sorta really recommend a tab width of

Re: Threading with queues

2009-12-22 Thread Lie Ryan
On 12/22/2009 10:47 AM, Gib Bogle wrote: This is indented over one indentation level too much. You want it to be at the same level as the for above. Here, its at the same level with "t" -- meaning this entire loop gets repeated five times. I sorta really recommend a tab width of 4 spaces, not 2

Re: Threading with queues

2009-12-21 Thread Gib Bogle
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 3:12 PM, Gib Bogle wrote: #spawn a pool of threads, and pass them queue instance for i in range(5): t = ThreadUrl(queue,i) t.setDaemon(True) t.start() #populate queue with data for host in hosts: queue.put(host) This is indent

Re: Threading with queues

2009-12-21 Thread Gib Bogle
Stephen Hansen wrote: On Mon, Dec 21, 2009 at 3:12 PM, Gib Bogle wrote: #spawn a pool of threads, and pass them queue instance for i in range(5): t = ThreadUrl(queue,i) t.setDaemon(True) t.start() #populate queue with data for host in hosts: queue.put(host) This is indent

Re: Threading with queues

2009-12-21 Thread Stephen Hansen
On Mon, Dec 21, 2009 at 3:24 PM, Stephen Hansen wrote: > This is indented over one indentation level too much. You want it to > be at the same level as the for above. Here, its at the same level > with "t" -- meaning this entire loop gets repeated five times. Err, "this" in this context meant the

Re: Threading with queues

2009-12-21 Thread Stephen Hansen
On Mon, Dec 21, 2009 at 3:12 PM, Gib Bogle wrote: >  #spawn a pool of threads, and pass them queue instance >  for i in range(5): >    t = ThreadUrl(queue,i) >    t.setDaemon(True) >    t.start() > >  #populate queue with data >    for host in hosts: >      queue.put(host) This is indented over o

Threading with queues

2009-12-21 Thread Gib Bogle
Hi, I'm learning Python, jumping in the deep end with a threading application. I came across an authoritative-looking site that recommends using queues for threading in Python. http://www.ibm.com/developerworks/aix/library/au-threadingpython/index.html The author provides example code that fet