Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'messages.': 0.04; 'except:': 0.07; 'exception.': 0.07; 'try:': 0.07; "'w')": 0.09; 'hiding': 0.09; 'of)': 0.09; 'subject:into': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; '"error': 0.16; '10:00': 0.16; 'cause.': 0.16; 'exit()': 0.16; 'investigate': 0.16; 'silly': 0.16; 'subject:writing': 0.16; 'utc,': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'causing': 0.20; 'trying': 0.21; 'exceptions': 0.22; 'cc:2**0': 0.23; 'errors': 0.23; 'monday,': 0.23; 'cc:no real name:2**0': 0.24; 'testing': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; '(which': 0.26; 'am,': 0.27; 'actual': 0.28; 'catching': 0.29; 'knows': 0.30; 'error': 0.30; 'code': 0.31; 'could': 0.32; 'print': 0.32; 'purposes,': 0.33; 'right?': 0.33; 'point.': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'thanks': 0.34; 'problem,': 0.35; 'there': 0.35; 'really': 0.36; 'michael': 0.36; 'but': 0.36; 'anything': 0.36; 'should': 0.36; 'possible': 0.37; 'ok,': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'your': 0.60; 'from:no real name:2**0': 0.60; 'skip:u 10': 0.60; 'kind': 0.61; 'information': 0.63; 'email addr:gmail.com': 0.63; 'answer.': 0.71; 'hand': 0.82; '2013': 0.84; 'case?': 0.84; 'contextual': 0.91; 'us?': 0.91 X-Received: by 10.49.70.195 with SMTP id o3mr748612qeu.3.1361265855251; Tue, 19 Feb 2013 01:24:15 -0800 (PST) Newsgroups: comp.lang.python Date: Tue, 19 Feb 2013 01:24:15 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=92.40.254.242; posting-account=EvoLHwoAAAAe6MGgc84vdAuhA1J1BvTN References: <76620a9e-45fe-499d-b1bf-06b1d2a91c25@googlegroups.com> <16e85bd1-6e5d-4d70-95bf-cc6b986a9f7c@googlegroups.com> <8f26ac4d-4732-46ac-bf4e-877696b22241@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 92.40.254.242 MIME-Version: 1.0 Subject: Re: improving performance of writing into a pipe From: mikprog@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: , Message-ID: Lines: 70 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361265864 news.xs4all.nl 6945 [2001:888:2000:d::a6]:55278 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39194 On Monday, February 18, 2013 6:12:01 PM UTC, Michael Torrie wrote: > On 02/18/2013 10:00 AM, mikprog@gmail.com wrote: > > > [..] > > >> > > >> I don't see an exception in your answer. Where did you put it for us? > > >> > > > > > > well I just did print a message: > > > > > > PIPEPATH = ["/tmp/mypipe"] > > > > > > [..] > > > try: > > > self.process = os.popen( self.PIPEPATH, 'w') > > > except: > > > print "Error while trying opening the pipe!" > > > print "check: ", self.PIPEPATH > > > exit() > > > > > > I see the error messages. > > > > Unfortunately your attempt to catch this exception is hiding the true > > cause. You need to give us the actual exception. Otherwise it could be > > anything from self.PIPEPATH not existing to who knows what. > > > > Almost never do you want to catch all exceptions like you're doing. You > > should only catch the specific exceptions you know how to deal with in > > your code. > > > > For testing purposes, if your code really is as you put it, then > catching exceptions is kind of silly since you're just re-raising the > exception (sort of) but without any contextual information that would > make the error meaningful. Ok, I get your point. But on the other hand how do I know what to catch if I have no clue what is causing the error? There must be a way to catch all the possible errors and then investigate what is the problem, right? (which is not what I have done so far). Or rather: what would you try to catch in this particular case? Thanks