On Thu, Apr 24, 2014 at 1:10 PM, Dylan Baker <baker.dyla...@gmail.com> wrote:
> Currently we call join after initializing both of the pools, which means
> that they run simultaneously. This patch fixes that by creating a helper
> function which sets off the pool, closes it, and then joins it. This
> fixes the problem by forcing each pool to run in series.
>
> v2: - Fix typo that put all tests in a multithreaded pool
>     - split lines differently for improved readability
>
> Signed-off-by: Dylan Baker <baker.dyla...@gmail.com>

Reviewed-by: Ilia Mirkin <imir...@alum.mit.edu>

> ---
>  framework/profile.py | 29 ++++++++++++++---------------
>  1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/framework/profile.py b/framework/profile.py
> index 2e160e3..10b062b 100644
> --- a/framework/profile.py
> +++ b/framework/profile.py
> @@ -116,6 +116,8 @@ class TestProfile(object):
>
>          framework.exectest.Test.ENV = env
>
> +        chunksize = 1
> +
>          self.prepare_test_list(env)
>          log = Log(len(self.test_list), env.verbose)
>
> @@ -128,33 +130,30 @@ class TestProfile(object):
>              name, test = pair
>              test.execute(name, log, json_writer, self.dmesg)
>
> +        def run_threads(pool, testlist):
> +            """ Open a pool, close it, and join it """
> +            pool.imap(test, testlist, chunksize)
> +            pool.close()
> +            pool.join()
> +
>          # Multiprocessing.dummy is a wrapper around Threading that provides a
>          # multiprocessing compatible API
>          #
>          # The default value of pool is the number of virtual processor cores
>          single = multiprocessing.dummy.Pool(1)
>          multi = multiprocessing.dummy.Pool()
> -        chunksize = 1
>
>          if env.concurrent == "all":
> -            multi.imap(test, self.test_list.iteritems(), chunksize)
> +            run_threads(multi, self.test_list.iteritems())
>          elif env.concurrent == "none":
> -            single.imap(test, self.test_list.iteritems(), chunksize)
> +            run_threads(single, self.test_list.iteritems())
>          else:
>              # Filter and return only thread safe tests to the threaded pool
> -            multi.imap(test, (x for x in self.test_list.iteritems() if
> -                              x[1].run_concurrent), chunksize)
> +            run_threads(multi, (x for x in self.test_list.iteritems()
> +                                if x[1].run_concurrent))
>              # Filter and return the non thread safe tests to the single pool
> -            single.imap(test, (x for x in self.test_list.iteritems() if not
> -                               x[1].run_concurrent), chunksize)
> -
> -        # Close and join the pools
> -        # If we don't close and the join the pools the script will exit 
> before
> -        # the pools finish running
> -        multi.close()
> -        single.close()
> -        multi.join()
> -        single.join()
> +            run_threads(single, (x for x in self.test_list.iteritems()
> +                                 if not x[1].run_concurrent))
>
>          log.summary()
>
> --
> 1.9.2
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to