Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: improving performance of writing into a pipe |
| Date | 2013-02-19 10:55 +0100 |
| Organization | None |
| References | (2 earlier) <16e85bd1-6e5d-4d70-95bf-cc6b986a9f7c@googlegroups.com> <kftm2l$b84$1@r03.glglgl.gl> <8f26ac4d-4732-46ac-bf4e-877696b22241@googlegroups.com> <mailman.1958.1361211131.2939.python-list@python.org> <85cd2254-0800-4448-9117-9175bbfd10f6@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2012.1361267738.2939.python-list@python.org> (permalink) |
mikprog@gmail.com wrote: > 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? Nothing. Once you get your script working you can try to provoke errors, and for those errors you can recover from you can write error handlers. For IOError and Python < 3.3 that may involve inspecting the errno attribute and conditionally reraising. By the way, I don't think >> > PIPEPATH = ["/tmp/mypipe"] >> > self.process = os.popen( self.PIPEPATH, 'w') can work. As a few people already told you the built-in open() with open(PIPEPATH, "w") as f: f.write(...) is the way to go.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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