• Home
  • Raw
  • Download

Lines Matching full:pool

2 # A test of `multiprocessing.Pool` class
52 # Create pool
56 print 'Creating pool with %d processes\n' % PROCESSES
57 pool = multiprocessing.Pool(PROCESSES)
58 print 'pool = %s' % pool
68 results = [pool.apply_async(calculate, t) for t in TASKS]
69 imap_it = pool.imap(calculatestar, TASKS)
70 imap_unordered_it = pool.imap_unordered(calculatestar, TASKS)
72 print 'Ordered results using pool.apply_async():'
77 print 'Ordered results using pool.imap():'
82 print 'Unordered results using pool.imap_unordered():'
87 print 'Ordered results using pool.map() --- will block till complete:'
88 for x in pool.map(calculatestar, TASKS):
105 B = pool.map(pow3, xrange(N))
110 C = list(pool.imap(pow3, xrange(N), chunksize=N//8))
111 print '\tlist(pool.imap(pow3, xrange(%d), chunksize=%d)):\n\t\t%s' \
127 B = pool.map(noop, L)
132 C = list(pool.imap(noop, L, chunksize=len(L)//8))
133 print '\tlist(pool.imap(noop, L, chunksize=%d)):\n\t\t%s seconds' % \
148 print pool.apply(f, (5,))
150 print '\tGot ZeroDivisionError as expected from pool.apply()'
155 print pool.map(f, range(10))
157 print '\tGot ZeroDivisionError as expected from pool.map()'
162 print list(pool.imap(f, range(10)))
164 print '\tGot ZeroDivisionError as expected from list(pool.imap())'
168 it = pool.imap(f, range(10))
190 res = pool.apply_async(calculate, TASKS[0])
202 it = pool.imap(calculatestar, TASKS)
223 r = pool.apply_async(mul, (7, 8), callback=A.append)
226 r = pool.map_async(pow3, range(10), callback=A.extend)
238 assert not pool._cache, 'cache = %r' % pool._cache
246 for worker in pool._pool:
249 result = pool.apply_async(time.sleep, [0.5])
250 pool.close()
251 pool.join()
255 for worker in pool._pool:
266 pool = multiprocessing.Pool(2)
268 ignore = pool.apply(pow3, [2])
269 results = [pool.apply_async(time.sleep, [DELTA]) for i in range(100)]
270 pool.terminate()
271 pool.join()
273 for worker in pool._pool:
284 pool = multiprocessing.Pool(2)
286 processes = pool._pool
287 ignore = pool.apply(pow3, [2])
288 results = [pool.apply_async(time.sleep, [DELTA]) for i in range(100)]
290 results = pool = None