Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38026

Python 2 multiprocessing examples in docs.python.org

From Xavier Ho <contact@xavierho.com>
Date 2013-02-01 15:14 +1100
Subject Python 2 multiprocessing examples in docs.python.org
Newsgroups comp.lang.python
Message-ID <mailman.1270.1359692111.2939.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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 "test.py", line 314, in <module>
    test()
  File "test.py", line 295, in test
    assert not worker.is_alive()
AssertionError

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.

Cheers,
Xav

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Python 2 multiprocessing examples in docs.python.org Xavier Ho <contact@xavierho.com> - 2013-02-01 15:14 +1100

csiph-web