Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39114

Re: improving performance of writing into a pipe

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem@gmail.com>
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; '"error': 0.16; '10:00': 0.16; 'cause.': 0.16; 'exit()': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'silly': 0.16; 'subject:writing': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'trying': 0.21; 'exceptions': 0.22; 'testing': 0.24; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 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; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'anything': 0.36; 'should': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'kind': 0.61; 'information': 0.63; 'email addr:gmail.com': 0.63; 'answer.': 0.71; 'contextual': 0.91; 'us?': 0.91
X-Virus-Scanned amavisd-new at torriefamily.org
Date Mon, 18 Feb 2013 11:12:01 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: improving performance of writing into a pipe
References <76620a9e-45fe-499d-b1bf-06b1d2a91c25@googlegroups.com> <mailman.1952.1361200943.2939.python-list@python.org> <16e85bd1-6e5d-4d70-95bf-cc6b986a9f7c@googlegroups.com> <kftm2l$b84$1@r03.glglgl.gl> <8f26ac4d-4732-46ac-bf4e-877696b22241@googlegroups.com>
In-Reply-To <8f26ac4d-4732-46ac-bf4e-877696b22241@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1958.1361211131.2939.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361211131 news.xs4all.nl 6908 [2001:888:2000:d::a6]:53584
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39114

Show key headers only | View raw


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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 07:12 -0800
  Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-18 15:21 +0000
    Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 08:31 -0800
      Re: improving performance of writing into a pipe Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-02-18 17:49 +0100
        Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 09:00 -0800
          Re: improving performance of writing into a pipe Michael Torrie <torriem@gmail.com> - 2013-02-18 11:12 -0700
            Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 01:24 -0800
              Re: improving performance of writing into a pipe Peter Otten <__peter__@web.de> - 2013-02-19 10:55 +0100
                Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 02:27 -0800
                Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-19 11:15 +0000
                Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 02:27 -0800
              Re: improving performance of writing into a pipe Michael Torrie <torriem@gmail.com> - 2013-02-19 10:47 -0700
                Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-20 09:54 -0800
                Re: improving performance of writing into a pipe John Gordon <gordon@panix.com> - 2013-02-20 18:39 +0000
                Re: improving performance of writing into a pipe Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-20 22:05 +0000
                Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-20 09:54 -0800
            Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 01:24 -0800
    Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-18 08:31 -0800
  Re: improving performance of writing into a pipe Serhiy Storchaka <storchaka@gmail.com> - 2013-02-18 21:29 +0200
    Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 04:10 -0800
    Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 04:10 -0800
    Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 05:39 -0800
      Re: improving performance of writing into a pipe Peter Otten <__peter__@web.de> - 2013-02-19 14:57 +0100
        Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 06:38 -0800
        Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 06:38 -0800
    Re: improving performance of writing into a pipe mikprog@gmail.com - 2013-02-19 05:39 -0800

csiph-web