Python 2 multiprocessing examples in docs.python.org

Discussion in 'Python' started by Xavier Ho, Feb 1, 2013.

  1. Xavier Ho

    Xavier Ho Guest

    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
     
    Xavier Ho, Feb 1, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KYG
    Replies:
    2
    Views:
    928
    Ian Collins
    Aug 18, 2008
  2. Brandon Craig Rhodes

    python docs redirect on python.org is old

    Brandon Craig Rhodes, Apr 5, 2009, in forum: Python
    Replies:
    2
    Views:
    271
    barisa
    Apr 5, 2009
  3. Stéphane Wirtel
    Replies:
    0
    Views:
    200
    Stéphane Wirtel
    Apr 19, 2007
  4. PerlFAQ Server
    Replies:
    0
    Views:
    702
    PerlFAQ Server
    Feb 3, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    708
    PerlFAQ Server
    Apr 4, 2011
Loading...

Share This Page