Re: improving performance of writing into a pipe

2013-02-20 Thread Oscar Benjamin
On 20 February 2013 17:54, wrote: > On Tuesday, February 19, 2013 5:47:16 PM UTC, Michael Torrie wrote: >> On 02/19/2013 02:24 AM, mikp...@gmail.com wrote: >> >> > Or rather: what would you try to catch in this particular case? >> >> >> As Peter said, nothing for now. But you seem very resistant

Re: improving performance of writing into a pipe

2013-02-20 Thread John Gordon
In mikp...@gmail.com writes: > As written before, I don't know what exception to search for, so I wrote > the (wrong) code: > except: > print "error" > Let's why I don't have a clue about it. > But someone already explained me that I should not do this. If you don't know what exception is be

Re: improving performance of writing into a pipe

2013-02-20 Thread mikprog
On Tuesday, February 19, 2013 5:47:16 PM UTC, Michael Torrie wrote: > On 02/19/2013 02:24 AM, mikp...@gmail.com wrote: > > > Or rather: what would you try to catch in this particular case? > > > As Peter said, nothing for now. But you seem very resistant to telling > > us what exception was ra

Re: improving performance of writing into a pipe

2013-02-19 Thread Michael Torrie
On 02/19/2013 02:24 AM, mikp...@gmail.com wrote: > Or rather: what would you try to catch in this particular case? As Peter said, nothing for now. But you seem very resistant to telling us what exception was raised. Though looking at your code more closely I can see that likely the error is rela

Re: improving performance of writing into a pipe

2013-02-19 Thread mikprog
> > Thanks a lot Serhiy to you and to everyone else. > > > Do you mind telling us what fix you applied? Oh, apologies Peter, I thought it was clear as I posted it after the lines written by Serhiy. So it was what Serhiy suggest in addition to some (?minor?) modification to the pipe itself, wh

Re: improving performance of writing into a pipe

2013-02-19 Thread Peter Otten
mikp...@gmail.com wrote: >> def write_to_pipe(line): >> hexbytes = ''.join('\\x%02x' % ord(c) for c in line) I thought this was only needed to have 'echo' except your data. >> with open('/tmp/mypipe', 'w') as f: >> f.write(hexbytes) > Update: > with a fix in the pipe THIS was

Re: improving performance of writing into a pipe

2013-02-19 Thread mikprog
> > def write_to_pipe(line): > > hexbytes = ''.join('\\x%02x' % ord(c) for c in line) > > with open('/tmp/mypipe', 'w') as f: > > f.write(hexbytes) Update: with a fix in the pipe THIS was the right way to do it, and it now works. Thanks a lot Serhiy to you and to everyone e

Re: improving performance of writing into a pipe

2013-02-19 Thread mikprog
On Monday, February 18, 2013 7:29:09 PM UTC, Serhiy Storchaka wrote: > On 18.02.13 17:12, mikp...@gmail.com wrote: > > > on an embedded linux system (BeagleBoard) I am writing data coming from > > bluetooth dongle into a pipe. > > > The function is the following one: > > > > > > > > > def wri

Re: improving performance of writing into a pipe

2013-02-19 Thread Oscar Benjamin
On 19 February 2013 10:27, wrote: >> can work. As a few people already told you the built-in open() > > > Few people? > I thought Oscar was a singular person, not a group of people :-) Serhiy also suggested it. > Seriously, I am convinced by that approach (thanks) and I wish to go that > way,

Re: improving performance of writing into a pipe

2013-02-19 Thread mikprog
> > 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. Ok. > By the way, I don't thi

Re: improving performance of writing into a pipe

2013-02-19 Thread Peter Otten
mikp...@gmail.com wrote: > On Monday, February 18, 2013 6:12:01 PM UTC, Michael Torrie wrote: >> On 02/18/2013 10:00 AM, mikp...@gmail.com wrote: >> >> > [..] >> >> >> >> >> >> I don't see an exception in your answer. Where did you put it for us? >> >> >> >> >> > >> >> > well I just did pri

Re: improving performance of writing into a pipe

2013-02-19 Thread mikprog
On Monday, February 18, 2013 6:12:01 PM UTC, Michael Torrie wrote: > On 02/18/2013 10:00 AM, mikp...@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

Re: improving performance of writing into a pipe

2013-02-18 Thread Serhiy Storchaka
On 18.02.13 17:12, mikp...@gmail.com wrote: on an embedded linux system (BeagleBoard) I am writing data coming from bluetooth dongle into a pipe. The function is the following one: def write_to_pipe(line): # next line ensures that bytes like '0x09' are not translated into '\t' for #

Re: improving performance of writing into a pipe

2013-02-18 Thread Michael Torrie
On 02/18/2013 10:00 AM, mikp...@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') >

Re: improving performance of writing into a pipe

2013-02-18 Thread mikprog
[..] > > 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!"

Re: improving performance of writing into a pipe

2013-02-18 Thread Thomas Rachel
Am 18.02.2013 17:31 schrieb mikp...@gmail.com: However I get an exception while trying to open the queue: fout = open('/tmp/mypipe', 'w') I don't see an exception in your answer. Where did you put it for us? I have tried it in a command line and the call doesn't return until in another ter

Re: improving performance of writing into a pipe

2013-02-18 Thread mikprog
On Monday, February 18, 2013 3:21:53 PM UTC, Oscar Benjamin wrote: [..] > > Can you not open the pipe file directly in Python code? e.g. > > > > fout = open('/tmp/mypipe', 'w') > > fout.write(data) > > > > I guess that this would be more efficient than using os.popen to run echo. > > tha

Re: improving performance of writing into a pipe

2013-02-18 Thread Oscar Benjamin
On 18 February 2013 15:12, wrote: > Hi guys, > > on an embedded linux system (BeagleBoard) I am writing data coming from > bluetooth dongle into a pipe. > The function is the following one: > > > def write_to_pipe(line): > > # next line ensures that bytes like '0x09' are not translated into

improving performance of writing into a pipe

2013-02-18 Thread mikprog
Hi guys, on an embedded linux system (BeagleBoard) I am writing data coming from bluetooth dongle into a pipe. The function is the following one: def write_to_pipe(line): # next line ensures that bytes like '0x09' are not translated into '\t' for #example, and they are sent as such