Given the following:
from time import sleep
def runTest(a):
sleep(1)
assert a >= 0
def test_all():
for i in range(5):
yield (runTest, i)
I would expect the five tests to get run in parallel running with nosetests --processes=8
and thus run in approximately one second — however, it takes just over five seconds to run: they appear to be running sequentially and not concurrently.
According to the nose documentation, the multiprocess plugin has supported test generators (as the nose documentation calls them) since 1.1: I'm using nose 1.3.0 so it should be supported. Adding _multiprocess_can_split_ = True
does make any difference, as one would expect, as fixtures are not used.
How do I get these five tests to run concurrently?
You may try
from time import sleep
from multiprocessing import Process
def runTest(a):
sleep(1)
assert a >= 0
def test_all():
for i in range(5):
Process(target=(yield (runTest, i))).start()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.