improving performance of writing into a pipe
mikprog at gmail.com
mikprog at gmail.com
Tue Feb 19 04:24:15 EST 2013
On Monday, February 18, 2013 6:12:01 PM UTC, Michael Torrie wrote:
> On 02/18/2013 10:00 AM, mikprog at 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
More information about the Python-list
mailing list