Im implementing multi threaded functionality using the design pattern discussed in this answer and this blog post.
My data source is dynamic (comes from web POSTs) but all the examples I can find uses a static data source.
My question is therefore: How can I implement multi threaded functionality with a non-static data input source?
Example-code:
import urllib2
from multiprocessing.dummy import Pool as ThreadPool
# This is a static data source. I need it to be dynamic!
urls = [
'http://www.python.org',
'http://www.python.org/about/',
# etc..
]
# Make the Pool of workers
pool = ThreadPool(4)
# Open the urls in their own threads
# and return the results
results = pool.map(urllib2.urlopen, urls)
#close the pool and wait for the work to finish
pool.close()
pool.join()