bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

Running nosetests with multiprocessing tests on Windows leads to infinite explosion of processes #398

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Create the following two files in a directory:

== run_nose.py =================
from nose import main
if __name__ == '__main__':
    main()
================================

== test_me.py ==================
from multiprocessing import Pool
import os, time

def foo(x):
    time.sleep(0.1)
    return (x, os.getpid())

def test_me():
    pool = Pool(processes=4)
    x = pool.map(foo, range(10))
    a, b = zip(*x)
    print a, b
    assert list(a) == range(10)
    assert 1 < len(set(b)) <= 4
================================

On Windows, if I go to the directory and type

c:\python27\python run_nose.py

...the tests run correctly. If I type

nosetests

...it causes an exponential explosion of processes

(Note, be careful if you try it, in my case I need to have a command window 
open with "taskkill /F /IM python.exe" ready, otherwise the computer locks up 
fairly quickly.)

This does not seem to be entirely nose specific since "python setup.py test" 
seems to do the same thing in my project. But I'm wondering if you have any 
insight into what's going on here.

Python 2.7, Windows 7, nosetests-script.py version 1.0.0

See http://bugs.python.org/issue11240 for more information.

Original issue reported on code.google.com by matt%who...@gtempaccount.com on 18 Feb 2011 at 9:48

GoogleCodeExporter commented 8 years ago
Sorry, forgot to mention: What seems to be happening in both cases ("nosetests" 
and "python setup.py test") based on the printed output is that each 
multiprocessing.Process that gets started executes the original command line 
("nosetests" or "python setup.py test"), so each process starts running the 
test suite, causing an infinite fan-out.

Original comment by matt%who...@gtempaccount.com on 18 Feb 2011 at 10:34