I just figured out a problem in our paste-based server which took a
LONG time for me (a decidedly non-network developer) to resolve.
One of my test cases checks to see that sending a POST request to a
GET service returns a correct 405 error, and that the message-body
contains an XML error document.
My regressions would sometimes fail with a
socket.error: [Errno 54] Connection reset by peer
It was more repeatable by doing 100 requests. Each request took 2
seconds. Doing the non-error version completes 100 requests in under a
second.
Eventually (so much happened in the 'eventually') I found a solution.
There was still wsgi.input data sitting there, untouched and unloved.
If I read one byte from it then everything was fine.
def wsgi_application(self, environ, start_response):
# There's some sort of problem if the application
# hasn't read any data. This can occur, for example,
# when sending a POST to a GET service, returning
# a 405 message.
wsgi_input = environ["wsgi.input"]
try:
return self._wsgi_application(environ, start_response)
finally:
# This seems to work even if there's 10K of input.
wsgi_input.read(1)
# If I really want to read all of the data ...
#while wsgi_input.read(100000):
# pass
def _wsgi_application(self, environ, start_response):
I haven't tracked this down inside of paste.htttpserver to figure out
what's going on.
Any comments?
Andrew
da...@dalkescientific.com