Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 07Jan2016 17:22, richard kappler wrote: On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson wrote: Just a few followup remarks: This is all Python 3, where bytes and strings are cleanly separated. You've got a binary stream with binary delimiters, so we're reading binary data and returning t

Re: [Tutor] reading an input stream

2016-01-07 Thread richard kappler
On Thu, Jan 7, 2016 at 5:07 PM, Cameron Simpson wrote: > > Just a few followup remarks: > > This is all Python 3, where bytes and strings are cleanly separated. > You've got a binary stream with binary delimiters, so we're reading binary > data and returning the binary XML in between. We separate

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 08Jan2016 08:52, Cameron Simpson wrote: [...] Instead, gather the data progressively and emit XML chunks. You've got a TCP stream - the TCPServer class will do an accept and handle you an _unbuffered_ binary stream file from which you can just .read(), ignoring any arbitrary "packet" sizes.

Re: [Tutor] reading an input stream

2016-01-07 Thread Cameron Simpson
On 07Jan2016 12:14, richard kappler wrote: On Thu, Jan 7, 2016 at 12:07 PM, James Chapman wrote: From an architectural POV I'd have a few listener threads that upon receipt would spawn (or take from a pool is a better approach) a worker thread to process the received data. As would I. That

Re: [Tutor] reading an input stream

2016-01-07 Thread James Chapman
Hi Richard There are a number of considerations you need to take into account here. Raw sockets is almost never the right solution, while a basic socket to socket connection is easy enough to program, handling failure and concurrency can very quickly make the solution a lot more complex than it n

Re: [Tutor] reading an input stream

2015-12-29 Thread richard kappler
Sorry it took so long to respond, just getting back from the holidays. You all have given me much to think about. I've read all the messages through once, now I need to go trough them again and try to apply the ideas. I'll be posting other questions as I run into problems. BTW, Danny, best explanat

Re: [Tutor] reading an input stream

2015-12-24 Thread eryk sun
On Thu, Dec 24, 2015 at 9:13 PM, boB Stepp wrote: > AttributeError: 'generator' object has no attribute 'next' The iterator protocol was added in Python 2.2 (circa 2001) as a generalization for use in "for" loops, but the language didn't have built-in next() at the time. Instead the method to get

Re: [Tutor] reading an input stream

2015-12-24 Thread Danny Yoo
numStream.next() > Traceback (most recent call last): > File "", line 1, in > numStream.next() > AttributeError: 'generator' object has no attribute 'next' > > > If I instead do this: > next(numStream) > 0 next(numStream) > 1 next(numStream) > 2 > > Things work as you des

Re: [Tutor] reading an input stream

2015-12-24 Thread Cameron Simpson
On 24Dec2015 13:54, richard kappler wrote: I have to create a script that reads xml data over a tcp socket, parses it and outputs it to console. Not so bad, most of which I already know how to do. I know how to set up the socket, though I am using a file for development and testing, am using lx

Re: [Tutor] reading an input stream

2015-12-24 Thread boB Stepp
On Thu, Dec 24, 2015 at 3:54 PM, Danny Yoo wrote: I tried to follow your example: > > For example, here's a generator that knows how to produce an infinite > stream of numbers: > > ## > def nums(): > n = 0 > while True: > yield n > n += 1 > ## > > W

Re: [Tutor] reading an input stream

2015-12-24 Thread Alan Gauld
On 24/12/15 18:54, richard kappler wrote: > I think what I need to do would be analogous to (pardon if I'm using the > wrong terminology, at this poing in the discussion I am officially out of > my depth) sending the input stream to a buffer(s) until the ETX for that > message comes in, shoot the

Re: [Tutor] reading an input stream

2015-12-24 Thread Danny Yoo
> I think what I need to do would be analogous to (pardon if I'm using the > wrong terminology, at this poing in the discussion I am officially out of > my depth) sending the input stream to a buffer(s) until the ETX for that > message comes in, shoot the buffer contents to the parser while accept

[Tutor] reading an input stream

2015-12-24 Thread richard kappler
I have to create a script that reads xml data over a tcp socket, parses it and outputs it to console. Not so bad, most of which I already know how to do. I know how to set up the socket, though I am using a file for development and testing, am using lxml and have created an xslt that does what I w