Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '2.7': 0.05; 'python': 0.07; 'concurrency': 0.09; 'okay': 0.09; 'scripts': 0.10; 'written': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'gil.': 0.16; 'threading': 0.16; 'with?': 0.16; 'tue,': 0.20; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'seems': 0.21; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'trying': 0.23; 'module,': 0.23; 'subject:code': 0.23; 'version': 0.25; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'instead': 0.26; 'message- id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'received:209.85.161': 0.29; 'class.': 0.29; 'yet': 0.30; "won't": 0.30; 'cc:addr:python.org': 0.31; '17,': 0.31; 'worker': 0.31; 'import': 0.32; 'things': 0.33; 'module': 0.33; 'using': 0.34; 'actually': 0.34; 'there': 0.35; 'flag': 0.35; 'replacement': 0.35; 'some': 0.37; 'should': 0.37; 'received:209.85': 0.37; 'run': 0.37; 'eric': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'pretty': 0.38; 'anything': 0.38; 'set': 0.39; 'received:209': 0.39; 'except': 0.39; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'direction.': 0.65; 'designed': 0.69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=BE8pnPefIsVdFnapDGBUJRQ+K9sC/DsmsDH1kYN9WQ4=; b=sdelq3RWpI8h00++2R2csuJ5RT2miXvlD8+kqllMbHL5rm8bePcLJEiFEb5m+zjv4e Z35AS1DGaohTQuBS4feyubSKuXALSKzEj4uEv6nJ2h3xD0cxHuGb47iYoANNNwvGRDT5 onInEu8J2W5m+m3KtNbpCOrVD7lnfpcUed4FY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=KKMYn0fCu8gF53ryNVnUBHQIcG9ZJasRsaoElCEL7JsrkSby6To1u48dleJ2H3snK/ ZqiLDbF2jkFHvlUioLGRl6yFBQbDcVXcqL8WJVLMZsfzOlLACh8rTFMUtna9J4/dCuQq EiiElJlmCj5NKknM8Vkl8g3ki3OsXOVN//M6g= MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Tue, 17 May 2011 15:18:14 -0600 Subject: Re: portable multiprocessing code To: Eric Frederich Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305667125 news.xs4all.nl 49042 [::ffff:82.94.164.166]:58345 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5617 On Tue, May 17, 2011 at 9:14 AM, Eric Frederich wrote: > I have written some code using Python 2.7 but I'd like these scripts > to be able to run on Red Hat 5's 2.4.3 version of Python which doesn't > have multiprocessing. > I can try to import multiprocessing and set a flag as to whether it is > available. =A0Then I can create a Queue.Queue instead of a > multiprocessing.Queue for the arg_queue and result_queue. > Without actually trying this yet it seems like things would work okay > except for the Worker class. =A0It seems I can conditionally replace > multiprocessing.Queue with Queue.Queue, but is there anything to > replace multiprocessing.Process with? Yes, threading.Thread. Pro: Since the multiprocessing module is designed to be a drop-in replacement for the threading module, it should also be pretty straight-forward to go in the reverse direction. Con: You won't have true concurrency because of the GIL. Cheers, Ian