From: W. Trevor King Date: Wed, 20 Oct 2010 23:20:14 +0000 (-0400) Subject: Disable pysawsim.manager.subproc is multiprocessing is missing. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=540898b1bf19401f64ab967f15ec4eeea53a0bc1;p=sawsim.git Disable pysawsim.manager.subproc is multiprocessing is missing. --- diff --git a/pysawsim/manager/subproc.py b/pysawsim/manager/subproc.py index d0bb007..ad0d64b 100644 --- a/pysawsim/manager/subproc.py +++ b/pysawsim/manager/subproc.py @@ -20,15 +20,21 @@ """Functions for running external commands on other hosts. """ -from multiprocessing import Manager, Process, Queue, cpu_count +try: + from multiprocessing import Manager, Process, Queue, cpu_count + _SKIP = '' +except ImportError, multiprocessing_error: + Process = object + _SKIP = ' # doctest: +SKIP' from .. import log from . import Job from .thread import ThreadManager, CLOSE_MESSAGE - class WorkerProcess (Process): def __init__(self, spawn_queue, receive_queue, *args, **kwargs): + if Process == object: + raise multiprocessing_error super(WorkerProcess, self).__init__(*args, **kwargs) self.spawn_queue = spawn_queue self.receive_queue = receive_queue @@ -50,27 +56,29 @@ class SubprocessManager (ThreadManager): >>> from time import sleep >>> from math import sqrt - >>> m = SubprocessManager() + >>> m = SubprocessManager()%(skip)s >>> group_A = [] - >>> for i in range(10): + >>> for i in range(10):%(skip)s ... t = max(0, 5-i) ... group_A.append(m.async_invoke(Job(target=sleep, args=[t]))) >>> group_B = [] - >>> for i in range(10): + >>> for i in range(10):%(skip)s ... group_B.append(m.async_invoke(Job(target=sqrt, args=[i], ... blocks_on=[j.id for j in group_A]))) - >>> jobs = m.wait(ids=[j.id for j in group_A[5:8]]) - >>> print sorted(jobs.values(), key=lambda j: j.id) + >>> jobs = m.wait(ids=[j.id for j in group_A[5:8]])%(skip)s + >>> print sorted(jobs.values(), key=lambda j: j.id)%(skip)s [, , ] - >>> jobs = m.wait() - >>> print sorted(jobs.values(), key=lambda j: j.id) + >>> jobs = m.wait()%(skip)s + >>> print sorted(jobs.values(), key=lambda j: j.id)%(skip)s ... # doctest: +NORMALIZE_WHITESPACE [, , , , , , , , , , , , , , , , ] - >>> m.teardown() - """ + >>> m.teardown()%(skip)s + """ % {'skip': _SKIP} def __init__(self, worker_pool=None): + if Process == object: + raise multiprocessing_error super(SubprocessManager, self).__init__(worker_pool=worker_pool) def _setup_queues(self):