Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Donn Cave <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Ron Garret <[EMAIL PROTECTED]> wrote: > > > The answer is obvious: select is looking only at the underlying socket, > > and not at the rfile buffers. > > > > So... is this a bug in select?

Re: Select weirdness

2007-04-23 Thread Klaas
On Apr 23, 9:51 am, Ron Garret <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > > > Twisted does this out of the box, for what it's worth. > > Thanks. I will look at that. There is also asyncore in the standard library, which is a ve

Re: Select weirdness

2007-04-23 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > The answer is obvious: select is looking only at the underlying socket, > and not at the rfile buffers. > > So... is this a bug in select? Or a bug in my code? Yes. I don't see any specific followup to this point, but it

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > Twisted does this out of the box, for what it's worth. Thanks. I will look at that. rg -- http://mail.python.org/mailman/listinfo/python-list

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 23 Apr 2007 04:33:22 -0300, Ron Garret <[EMAIL PROTECTED]> > escribió: > > > I have not been able to find a proxy server that can proxy to unix > > sockets, so I need to write my own. Conceptually its a v

Re: Select weirdness

2007-04-23 Thread Jean-Paul Calderone
On Mon, 23 Apr 2007 00:33:22 -0700, Ron Garret <[EMAIL PROTECTED]> wrote: >In article <[EMAIL PROTECTED]>, > Irmen de Jong <[EMAIL PROTECTED]> wrote: > >> Ron Garret wrote: >> > I don't understand why socketserver calling select should matter. (And >> > BTW, there are no calls to select in SocketS

Re: Select weirdness

2007-04-23 Thread Gabriel Genellina
En Mon, 23 Apr 2007 04:33:22 -0300, Ron Garret <[EMAIL PROTECTED]> escribió: > I have not been able to find a proxy server that can proxy to unix > sockets, so I need to write my own. Conceptually its a very simple > thing: read the first line of an HTTP request, parse it with a regexp to > ext

Re: Select weirdness

2007-04-23 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Irmen de Jong <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > I don't understand why socketserver calling select should matter. (And > > BTW, there are no calls to select in SocketServer.py. I'm using > > Python2.5.) > > You don't *need* a select at all. Y

Re: Select weirdness

2007-04-22 Thread Irmen de Jong
Ron Garret wrote: > I don't understand why socketserver calling select should matter. (And > BTW, there are no calls to select in SocketServer.py. I'm using > Python2.5.) You don't *need* a select at all. Socketserver just blocks on accept() and dispatches a handler on the new connection. >>

Re: Bug in select (was: Re: Select weirdness)

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > Well, on WinXP, Python 2.4, with I should have specified: I'm running 2.5 on unix. (I've reproduced the problem on both Linux and OS X.) rg -- http://mail.python.org/mailman/listinfo/python-list

Bug in select (was: Re: Select weirdness)

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > The answer is obvious: select is looking only at the underlying socket, > and not at the rfile buffers. Here is conclusive proof that there's a bug in select: from socket import * from select import select s=socket(AF_INET

Re: Select weirdness

2007-04-22 Thread Jean-Paul Calderone
On Sun, 22 Apr 2007 11:42:10 -0700, Ron Garret <[EMAIL PROTECTED]> wrote: >I think I've figured out what's going on. > > [snip] > >As you can see, the select call shows input available for a while (five >lines) and then shows no input available despite the fact that there is >manifestly still input

Re: Select weirdness

2007-04-22 Thread Ron Garret
I think I've figured out what's going on. First, here's the smoking gun: I changed the code as follows: class myHandler(StreamRequestHandler): def handle(self): print '>>>' while 1: sl = select([self.rfile],[],[],1)[0] print sl l = self.rfile.readline() i

Re: Select weirdness

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Ron Garret <[EMAIL PROTECTED]> wrote: > Here's my code. It's a teeny weeny little HTTP server. (I'm not really > trying to reinvent the wheel here. What I'm really doing is writing a > dispatching proxy server, but this is the shortest way to illustrate the >

Re: Select weirdness

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Irmen de Jong <[EMAIL PROTECTED]> wrote: > Ron Garret wrote: > > Here's my code. It's a teeny weeny little HTTP server. (I'm not really > > trying to reinvent the wheel here. What I'm really doing is writing a > > dispatching proxy server, but this is the shor

Re: Select weirdness

2007-04-22 Thread Ron Garret
In article <[EMAIL PROTECTED]>, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > > The only difference I can discern is that the browser send \r\n > > for end-of-line while telnet just sends \n. ... > > But I don't see why that should make any difference. > > Easy. If you only accept "\r\n

Re: Select weirdness

2007-04-22 Thread Irmen de Jong
Ron Garret wrote: > Here's my code. It's a teeny weeny little HTTP server. (I'm not really > trying to reinvent the wheel here. What I'm really doing is writing a > dispatching proxy server, but this is the shortest way to illustrate the > problem I'm having): > > from SocketServer import *

Re: Select weirdness

2007-04-22 Thread Bjoern Schliessmann
Ron Garret wrote: > print>>self.wfile, 'HTTP/1.0 200 OK' > print>>self.wfile, 'Content-type: text/plain' > print>>self.wfile > print>>self.wfile, 'foo' > [...] > If I telnet into this server and type in an HTTP request manually > it works fine. But when I try to access this with a

Select weirdness

2007-04-21 Thread Ron Garret
Here's my code. It's a teeny weeny little HTTP server. (I'm not really trying to reinvent the wheel here. What I'm really doing is writing a dispatching proxy server, but this is the shortest way to illustrate the problem I'm having): from SocketServer import * from socket import * from sele