gesomax / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Patch: Add thread safety to connection reuse #66

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I've been using httplib2 for the new windmill proxy code:

http://github.com/mikeal/windmill/tree/newproxy

httplib.HTTPConnection is not thread safe but since httplib2 knows when it
is done reading from the connection it can actually hack thread safety into
it's reuse of the connection instance it keeps around.

The code in windmill is a little specific since I had to customize the
_conn_request and delay the read on the connection but I took the time to
adapt the thread safety work into an httplib2 patch.

The patch should be attached.

Original issue reported on code.google.com by mikeal.rogers on 7 Sep 2009 at 11:38

Attachments:

GoogleCodeExporter commented 8 years ago
I also encountered this same issue.

I wrote a simple patch that includes the current thread ID in the connection 
dictionary.  Consequently, multiple connections (per process) can be cached.

Original comment by usaa...@gmail.com on 2 Feb 2010 at 6:51

Attachments:

GoogleCodeExporter commented 8 years ago
BTW, the patch I originally attached to this bug is used to work around this 
issue in
Windmill and was committed to our github master back in September.

It's being used by thousands of people without any known issues, so if anyone 
was
worried about it being safe we can attest to it.

Original comment by mikeal.rogers on 2 Feb 2010 at 5:09