Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion httplib branch
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Matt Goodall  
View profile  
 More options Sep 9 2009, 8:58 am
From: Matt Goodall <matt.good...@gmail.com>
Date: Wed, 9 Sep 2009 13:58:59 +0100
Local: Wed, Sep 9 2009 8:58 am
Subject: Re: httplib branch

2009/9/9 Christopher Lenz <cml...@gmx.de>

> On 09.09.2009, at 12:19, Matt Goodall wrote:
> > I'll switch over to using it locally to test it out a bit. However,
> > I just played with it in a Python shell and got a BadStatusLine
> > exception after a couple of requests. I'll take a look later (got
> > some work to do first) and report back.

> I think that *may* be due to unread content on the socket from a
> previous response.

No, looks like an inactivity problem.

Mochiweb (the CouchDB web server component, for those that don't know) has a
default idle timeout of 30s after which it closes the connection. The
httplib branch does not appear to be handling closed connections well yet.
The standard httplib module raises a BadStatusError to indicate a (probably)
closed connection.

I guess it's fair to assume that if a valid status line is not sent back
then the server either didn't receive the request or died before it had the
chance to do anything with it. So, catching a BadStatusError, recycling the
connection and trying again is probably reasonable and, unlike httplib2, the
only time it should retry IMHO.

I don't know of any other way to detect a closed socket. IIRC, a closed
socket just looks readable after a select.select() call and you have to read
at least 1 byte to find out if there's really any data or if it's been
closed. Not very helpful and, besides, messing around with select is
probably going to lead into cross-platform problems.

- Matt

> One note on downloading attachments, as that's not documented on the
> branch yet: any non-JSON and non-empty response entity body is
> returned as a file-like object, which is either a simple StringIO
> wrapper (for small responses) or a couchdb.http.ResponseBody instance
> (a thin layer over the underlying socket).

> So whenever you get non-JSON data, which is the case for attachments
> [1], you need to either fully consume the response via .read
> ([amount]), or call its .close() method. Both result in the connection
> returning into a reusable state.

> Perhaps we can detect connections left in unusable state, and just
> close/reconnect in that case. Although, now that I think about it, if
> you don't consume/close a ResponseBody, the associated connection is
> not returned to the connection pool, either. Hm.

> Cheers,
> --
> Christopher Lenz
>   cmlenz at gmx.de
>   http://www.cmlenz.net/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.