Python 2 multiprocessing examples in


Xavier Ho

Hey all,

I ran the example code on multiprocessing. On the "Pool example", an
assertion failed with "testing garbage collection".

Traceback (most recent call last):
File "", line 314, in <module>
File "", line 295, in test
assert not worker.is_alive()

The relevant example code reads:

pool = multiprocessing.Pool(2)
DELTA = 0.1
processes = pool._pool
ignore = pool.apply(pow3, [2])
results = [pool.apply_async(time.sleep, [DELTA]) for i in range(100)]

results = pool = None

time.sleep(DELTA * 2)

for worker in processes:
assert not worker.is_alive()

My questions are 1) How does that GC test work, and 2) Does that mean my GC
isn't working as fast as it should have been?

The machine's Python:

xav â– /tmp > python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question