From af88e5129b78954c744b15d15e09055c9624b128 Mon Sep 17 00:00:00 2001 From: Jose Idar Date: Mon, 25 Apr 2016 13:47:16 -0500 Subject: [PATCH] Added support for the multiprocess library in all unittest runners * Adds the pathos_multiprocess plugin which serves only to install the multiprocess package. If installed, it will be used by all unittest runners instead of the default multiprocessing library. Change-Id: Id18ee56d3fb1466f038aaa8c6fd9e2d890847f9e --- cafe/drivers/unittest/runner.py | 11 ++++++++- cafe/drivers/unittest/runner_parallel.py | 14 ++++++++--- cafe/plugins/pathos_multiprocess/setup.py | 30 +++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 cafe/plugins/pathos_multiprocess/setup.py diff --git a/cafe/drivers/unittest/runner.py b/cafe/drivers/unittest/runner.py index 58ee292..66d21ee 100755 --- a/cafe/drivers/unittest/runner.py +++ b/cafe/drivers/unittest/runner.py @@ -20,7 +20,6 @@ import unittest import uuid from importlib import import_module from inspect import isclass -from multiprocessing import Process, Manager from re import search from traceback import print_exc from cafe.common.reporting import cclogging @@ -31,6 +30,16 @@ from cafe.drivers.unittest.decorators import ( from cafe.drivers.unittest.parsers import SummarizeResults from cafe.drivers.unittest.suite import OpenCafeUnittestTestSuite +# Support for the alternate dill-based multiprocessing library 'multiprocess' +# as an experimental workaround if you're having pickling errors. +try: + from multiprocess import Process, Manager + sys.stdout.write( + "\n\nUtilizing the pathos multiprocess library. " + "This feature is experimental\n\n") +except: + from multiprocessing import Process, Manager + def tree(directory, padding, print_files=False): """ diff --git a/cafe/drivers/unittest/runner_parallel.py b/cafe/drivers/unittest/runner_parallel.py index f60a30d..9269ffa 100644 --- a/cafe/drivers/unittest/runner_parallel.py +++ b/cafe/drivers/unittest/runner_parallel.py @@ -12,18 +12,26 @@ # under the License. from __future__ import print_function +import sys + +# Support for the alternate dill-based multiprocessing library 'multiprocess' +# as an experimental workaround if you're having pickling errors. +try: + from multiprocess import Process, Queue + sys.stdout.write( + "\n\nUtilizing the pathos multiprocess library. " + "This feature is experimental\n\n") +except: + from multiprocessing import Process, Queue -from multiprocessing import Process, Queue from StringIO import StringIO from unittest.runner import _WritelnDecorator import importlib import logging import os -import sys import time import traceback import unittest - from cafe.common.reporting import cclogging from cafe.common.reporting.reporter import Reporter from cafe.configurator.managers import TestEnvManager diff --git a/cafe/plugins/pathos_multiprocess/setup.py b/cafe/plugins/pathos_multiprocess/setup.py new file mode 100644 index 0000000..f6a6d3b --- /dev/null +++ b/cafe/plugins/pathos_multiprocess/setup.py @@ -0,0 +1,30 @@ +# Copyright 2015 Rackspace +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +""" +This plugin installs the pathos multiprocess package. +Since pathos multiprocess is still in Beta, this plugin is considered +experimental. + +If installed, the cafe unittest runners will use multiprocess instead of +python's default multiprocessing library. +""" +from setuptools import setup + +setup( + name='cafe_pathos_multiprocess_plugin', + version='0.0.1', + description='The Common Automation Framework Engine', + author='Rackspace Cloud QE', + author_email='cloud-cafe@lists.rackspace.com', + url='http://rackspace.com', + install_requires=['multiprocess'])