Hello,

I'm not sure if this is the right forum for this question or if the paste-users 
list is more appropriate. Trying here first.

I'm trying to reuse http connections when talking to my pylons application 
using 
httplib. However, the Paste WSGI server closes the connection before it can be 
reused. This results in the client not being able to read a valid response from 
the connection.

Here's a small example:

 >>> import httplib
 >>> con = httplib.HTTPConnection('localhost', 80)
 >>> con.set_debuglevel(1)
 >>> con.request('GET', '/appinfo/')
send: 'GET /appinfo/ HTTP/1.1\r\nHost: localhost\r\nAccept-Encoding: 
identity\r\n\r\n'
 >>> res = con.getresponse()
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Wed, 18 Nov 2009 18:27:36 GMT
header: Server: PasteWSGIServer/0.5 Python/2.6
header: content-type: application/json
header: pragma: no-cache
header: cache-control: no-cache
header: Transfer-Encoding: chunked
 >>> res.read()
'{"status": {"code": 200, "response": "OK"}, "result": "Running since Wed Nov  
4 
19:47:29 2009 UTC"}'
 >>> con.request('GET', '/appinfo/')
send: 'GET /appinfo/ HTTP/1.1\r\nHost: localhost\r\nAccept-Encoding: 
identity\r\n\r\n'
 >>> res = con.getresponse()
reply: ''
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib/python2.6/httplib.py", line 974, in getresponse
     response.begin()
   File "/usr/lib/python2.6/httplib.py", line 391, in begin
     version, status, reason = self._read_status()
   File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
     raise BadStatusLine(line)
httplib.BadStatusLine


It seems there's an open bug in python to get httplib to handle closed 
connections better: http://bugs.python.org/issue3566. Still, the problem I'm 
trying to solve is how to keep the connection open.

Thanks,
   - Shailesh

--

You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.


Reply via email to