[Piglit] [PATCH] framework/profile.py: raise exception from pool.

Jose Fonseca jfonseca at vmware.com
Mon Dec 7 14:26:02 PST 2015


On 07/12/15 19:40, Dylan Baker wrote:
> On Mon, Dec 07, 2015 at 10:53:10AM -0800, baker.dylan.c at gmail.com wrote:
>> From: Dylan Baker <baker.dylan.c at gmail.com>
>>
>> By using Multiprocessing.dummy.Pool.apply_async() instead of .imap(), an
>> exception in the thread can be raised stopping the run of the suite.
>>
>> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
>> cc: jfonseca at vmware.com
>> ---
>>
>> This appears to work in my (brief) testing. It seems entirely too simple
>> for how painful multi-threading usually is in python, but it also
>> appears to work when I hack an exception into Test.execute.
>>
>>   framework/profile.py | 9 ++++-----
>>   1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/framework/profile.py b/framework/profile.py
>> index 32ed759..cb893db 100644
>> --- a/framework/profile.py
>> +++ b/framework/profile.py
>> @@ -248,21 +248,20 @@ class TestProfile(object):
>>
>>           self._pre_run_hook()
>>
>> -        chunksize = 1
>> -
>>           self._prepare_test_list()
>>           log = LogManager(logger, len(self.test_list))
>>
>> -        def test(pair):
>> +        def test(name, test):
>>               """Function to call test.execute from map"""
>> -            name, test = pair
>>               with backend.write_test(name) as w:
>>                   test.execute(name, log.get(), self.dmesg)
>>                   w(test.result)
>>
>>           def run_threads(pool, testlist):
>>               """ Open a pool, close it, and join it """
>> -            pool.imap(test, testlist, chunksize)
>> +            for pair in testlist:
>> +                x = pool.apply_async(test, pair)
>> +                x.get()
>>               pool.close()
>>               pool.join()
>>
>> --
>> 2.6.3
>
> Err, nevermind. This is close, but not quite what we want. v2 with more
> testing soon.

FWIW, I think it's fine to leave wildcard except (or move it to the top 
function called by multithreading.)

Hack for hack, whichever is reliable and less magic is the best.  My 
main concern is exceptions being hidden.

Jose


More information about the Piglit mailing list