473,326 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

httplib.ResponseNotReady question

Max
Hi, Group.

I'm not a Python programmer so this question may be really basic or
stupid. :) I have some code that sends a simple request to an
end-point and reads the response. That works just fine. When I put
the code in a for loop though I get httplib.ResponseNotReady error
message. It seems to me that I cannot call the requestor.getreply()
multiple times on the same requestor object. Anyway, here's the part
of my code that is causing the problem (I hope the format is
preserved...).

def sendRequest( msg, loops ):
requestor = httplib.HTTP(SERVER_ADDR, SERVER_PORT)
requestor.putrequest("POST", "/path/to/endpoint")
requestor.putheader("Host", SERVER_ADDR)
requestor.putheader("Content-Type", "text/xml")
requestor.putheader("Content-Length", str(len( msg ) ) )
requestor.endheaders()
for i in range(loops):
requestor.send( msg )
print "[" + str(i) + "] Message Sent : " +
time.strftime('%H:%M:%S', time.localtime())
(status_code, message, reply_headers) = requestor.getreply()
print "[" + str(i) + "] Response Received : " +
str(status_code)
print "[" + str(i) + "] Status : " +
time.strftime('%H:%M:%S', time.localtime())
print "-----[ break ]-----"

If I run this with loops=1 then everything works fine. If I use a
number greater than 1 then I get the error. Is there a method call
that I need to restore the requestor object to a condition where it's
eligible to receive another response?

Thanks, Max

Nov 13 '06 #1
2 7490
Max wrote:
If I run this with loops=1 then everything works fine. If I use a
number greater than 1 then I get the error. Is there a method call
that I need to restore the requestor object to a condition where it's
eligible to receive another response?
I'm pretty sure that to get a new response from the server, you need to
make a new request.

</F>

Nov 13 '06 #2
Max

Fredrik Lundh wrote:
Max wrote:
If I run this with loops=1 then everything works fine. If I use a
number greater than 1 then I get the error. Is there a method call
that I need to restore the requestor object to a condition where it's
eligible to receive another response?

I'm pretty sure that to get a new response from the server, you need to
make a new request.

</F>
I think you are right. I found a note in the documentation that says
the connection is good for one transaction.

Thanks, Max

Nov 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Manlio Perillo | last post by:
Hi. I'm not sure of this. When one do an HEAD command, no response body is returned. But httplib does not check this and when I do another request without first calling HTTPResponse.read, raises...
4
by: Adrian Albisser | last post by:
Hey to everybody, im just beginning to program in python. So i was trying some function but always when i try the range function i get a error message. for number in range(1,100): print number...
1
by: Brian Beck | last post by:
Hi. I'm having some problems with code based directly on the following httplib documentation code: http://www.zvon.org/other/python/doc21/lib/httplib-examples.html I've included the code and...
0
by: Gandalf | last post by:
Hi All, There was a discussion about a bug in httplib. After 100 (continue), when you want to GET a page, you will get a ResponseNotReady exception instead. I'm having the same problem here....
0
by: Leon | last post by:
I use sniffer look,it's status is 200,but run getresponse() can occur error ResponseNotReady I try wait it by 5 seconds,but still occur error ResponseNotReady source code.... import...
0
by: Laszlo Zsolt Nagy | last post by:
Hello, This is from the docs, from section 11.6.1 (HTTPConnection Objects) HTTPConnection instances have the following methods: request( method, url]) The headers argument should be a...
1
by: Mitch.Garnaat | last post by:
Hi - I'm writing some Python code to interact with Amazon's S3 service. One feature of S3 is that it will allow you to use the HTTP HEAD request to retrieve metadata about an S3 object without...
5
by: scott | last post by:
Hello, From a shell script, I have used /usr/bin/curl to access a web site and pass a cookie (as required by the site). But, I can't seem to accomplish this task with Python. I would like to...
0
by: Dustin J. Mitchell | last post by:
I'm building an interface to Amazon's S3, using httplib. It uses a single object for multiple transactions. What's happening is this: HTTP PUT /unitest-temp-1161039691 HTTP/1.1 HTTP Date: Mon,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.