Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39210
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-02-19 04:10 -0800 |
| References | <76620a9e-45fe-499d-b1bf-06b1d2a91c25@googlegroups.com> <mailman.1962.1361215987.2939.python-list@python.org> |
| Subject | Re: improving performance of writing into a pipe |
| From | mikprog@gmail.com |
| Message-ID | <mailman.2017.1361275844.2939.python-list@python.org> (permalink) |
On Monday, February 18, 2013 7:29:09 PM UTC, Serhiy Storchaka wrote:
> On 18.02.13 17:12, mikprog@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
>
> > #example, and they are sent as such
>
> > hexbytes = "\\x" + "\\x".join([hex(ord(c))[2:].zfill(2) for c in line])
>
> > wrap = ["echo -en '", "' > /tmp/mypipe"]
>
> > msg = hexbytes.join(wrap)
>
> > print "DBG: sending: ", msg
>
> >
>
> > try:
>
> > os.popen( msg )
>
> > except:
>
> > print "Error: write_to_pipe has failed!"
>
> >
>
> >
>
> > Now I typically receive 4 bytes from the bluetooth dongle and that is fine.
>
> > However when I receive many more than that it seems that the writing into the pipe is too slow.
>
> >
>
> > Is there any clever/obvious way to improve the code above?
>
> > (I am quite sure there is to be honest).
>
>
>
> 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)
I'll take your hexbytes = '' line (which is surely more efficient than mine).
However whit this approach open + write it seems the pipe doesn't get the data...
I am not sure what is going on.
At this point I suspect it could be a problem on the pipe itself (which I inherited).
It is just weird that the pipe accept this correctly:
wrap = ["echo -en '", "' > /tmp/midi"]
msg = hexbytes.join(wrap)
os.popen( msg )
but seems to be careless of approach open + write.
I need to investigate there.
Thanks a lot, to you and to everyone else.
Mik
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