[Piglit] [PATCH] framework/profile.py: raise exception from pool.
Dylan Baker
baker.dylan.c at gmail.com
Mon Dec 7 11:40:47 PST 2015
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20151207/4b8f6e28/attachment.sig>
More information about the Piglit
mailing list