Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; '"""': 0.07; 'skip:" 60': 0.07; 'builtin': 0.09; 'get(self,': 0.09; 'subject:module': 0.09; 'python': 0.11; 'def': 0.12; "'''": 0.16; '(also': 0.16; '(note': 0.16; 'concatenate': 0.16; 'iterable,': 0.16; 'received:mac.com': 0.16; 'self._state': 0.16; 'subject:Problem': 0.16; 'targets': 0.16; 'typeerror:': 0.16; 'fix': 0.17; 'received:10.0.1': 0.19; 'error': 0.23; 'finally,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'function': 0.29; 'raise': 0.29; 'strongly': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'assert': 0.31; 'time:': 0.31; 'file': 0.32; 'run': 0.32; 'up.': 0.33; 'running': 0.33; 'mac': 0.33; 'skip:# 10': 0.33; "i'd": 0.34; 'could': 0.34; 'problem': 0.35; 'basic': 0.35; 'objects': 0.35; 'there': 0.35; 'really': 0.36; 'library.': 0.36; 'module.': 0.36; 'doing': 0.36; 'charset :us-ascii': 0.36; 'received:10.0': 0.36; 'turn': 0.37; 'received:10': 0.37; 'being': 0.38; 'remote': 0.38; 'received:17': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'bill': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'tell': 0.60; 'simple': 0.61; 'save': 0.62; 'confirm': 0.64; 'map': 0.64; 'more': 0.64; 'different': 0.65; '20,': 0.68; 'harness': 0.84; 'subject:skip:M 10': 0.84; 'suspicion': 0.84; 'exposing': 0.91; 'hands': 0.96 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794,1.0.431,0.0.0000 definitions=2013-10-11_05:2013-10-11,2013-10-11,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1308280000 definitions=main-1310110055 From: William Ray Wing Content-type: text/plain; charset=us-ascii Content-transfer-encoding: quoted-printable Subject: Problem in Multiprocessing module Date: Fri, 11 Oct 2013 10:53:41 -0400 To: python-list@python.org MIME-version: 1.0 (Mac OS X Mail 6.6 \(1510\)) X-Mailer: Apple Mail (2.1510) Cc: William Ray Wing X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381506855 news.xs4all.nl 15952 [2001:888:2000:d::a6]:53187 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56690 I'm running into a problem in the multiprocessing module. My code is running four parallel processes which are doing network = access completely independently of each other (gathering data from = different remote sources). On rare circumstances, the code blows up = when one of my processes has do start doing some error recovery. I = strongly suspect it is because there is a time-out that isn't being = caught in the multiprocessing lib, and that in turn is exposing the = TypeError. Note that the error is "cannot concatenate 'str' and = 'NoneType' objects and it is occurring way down in the multiprocessing = library. I'd really appreciate it if someone more knowledgeable about = multiprocessing could confirm (or refute) my suspicion and then tell me = how to fix things up.=20 I'm running python 2.7.5 on a Mac OS-X 10.8.5 The traceback I get is: TypeError: cannot concatenate 'str' and 'NoneType' objects File = "/Users/wrw/Dev/Python/Connection_Monitor/Version3.0/CM_Harness.py", = line 20, in my_pool =3D pool.map(monitor, targets) # and hands off to four = targets File = "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiproc= essing/pool.py", line 250, in map return self.map_async(func, iterable, chunksize).get() File = "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiproc= essing/pool.py", line 554, in get raise self._value To save you-all some time: The "get" function at line 554 in pool.py (which is in the = multiprocessing lib) is: def get(self, timeout=3DNone): self.wait(timeout) if not self._ready: raise TimeoutError if self._success: return self._value else: raise self._value And the map function (also in pool in the multiprocessing lib) is: def map(self, func, iterable, chunksize=3DNone): ''' Equivalent of `map()` builtin ''' assert self._state =3D=3D RUN return self.map_async(func, iterable, chunksize).get() Finally, my code that calls all this is pretty simple (note that the = targets are dummies here): #!/usr/bin/env python """ Harness to call multiple parallel copies of the basic monitor program """ targets =3D ["www.sdsc.edu", "www.ncsa.edu", "www.uiuc.edu", = "www.berkeley.edu"] pool =3D Pool(processes=3D4) # start 4 worker processes my_pool =3D pool.map(monitor, targets) # and hands off to four = targets TiA Bill