You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2012/11/19 00:25:41 UTC

svn commit: r1411019 - in /libcloud/branches/0.11.x: ./ CHANGES libcloud/common/base.py libcloud/storage/drivers/s3.py

Author: tomaz
Date: Sun Nov 18 23:25:40 2012
New Revision: 1411019

URL: http://svn.apache.org/viewvc?rev=1411019&view=rev
Log:
Backport bug-fix commit from trunk:

Fix a bug which caused the connection to not be closed when using Python
2.6 and calling get_object on an object which doesn't exist in the S3
driver.

Contributed by John Carr, part of LIBCLOUD-257.

Modified:
    libcloud/branches/0.11.x/   (props changed)
    libcloud/branches/0.11.x/CHANGES
    libcloud/branches/0.11.x/libcloud/common/base.py
    libcloud/branches/0.11.x/libcloud/storage/drivers/s3.py

Propchange: libcloud/branches/0.11.x/
------------------------------------------------------------------------------
  Merged /libcloud/trunk:r1408567

Modified: libcloud/branches/0.11.x/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/branches/0.11.x/CHANGES?rev=1411019&r1=1411018&r2=1411019&view=diff
==============================================================================
--- libcloud/branches/0.11.x/CHANGES (original)
+++ libcloud/branches/0.11.x/CHANGES Sun Nov 18 23:25:40 2012
@@ -8,6 +8,18 @@ Changes with Apache Libcloud in developm
       ; LIBCLOUD-260
       [Dan Di Spaltro]
 
+    - Fix a bug which caused the connection to not be closed when using Python
+      2.6 and calling get_object on an object which doesn't exist in the S3
+      driver. ; LIBCLOUD-257
+      [John Carr]
+
+  *) DNS
+
+    - Update 'if type' checks in the update_record methods to behave correctly
+      if users passes in RecordType.A with a value of 0 - if type is not None.
+      ; LIBCLOUD-247
+      [Tomaz Muraus]
+
 Changes with Apache Libcloud 0.11.3:
 
   *) Storage

Modified: libcloud/branches/0.11.x/libcloud/common/base.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.11.x/libcloud/common/base.py?rev=1411019&r1=1411018&r2=1411019&view=diff
==============================================================================
--- libcloud/branches/0.11.x/libcloud/common/base.py (original)
+++ libcloud/branches/0.11.x/libcloud/common/base.py Sun Nov 18 23:25:40 2012
@@ -44,6 +44,23 @@ from libcloud.httplib_ssl import Libclou
 LibcloudHTTPConnection = httplib.HTTPConnection
 
 
+class HTTPResponse(httplib.HTTPResponse):
+    # On python 2.6 some calls can hang because HEAD isn't quite properly
+    # supported.
+    # In particular this happens on S3 when calls are made to get_object to
+    # objects that don't exist.
+    # This applies the behaviour from 2.7, fixing the hangs.
+    def read(self, amt=None):
+        if self.fp is None:
+            return ''
+
+        if self._method == 'HEAD':
+            self.close()
+            return ''
+
+        return httplib.HTTPResponse.read(self, amt)
+
+
 class Response(object):
     """
     A Base Response class to derive from.
@@ -267,9 +284,14 @@ class LoggingConnection():
             ht += "\r\n0\r\n"
         else:
             ht += u(body)
-        rr = httplib.HTTPResponse(sock=fakesock(ht),
-                                  method=r._method,
-                                  debuglevel=r.debuglevel)
+
+        if sys.version_info >= (2, 6) and sys.version_info < (2, 7):
+            cls = HTTPResponse
+        else:
+            cls = httplib.HTTPResponse
+
+        rr = cls(sock=fakesock(ht), method=r._method,
+                 debuglevel=r.debuglevel)
         rr.begin()
         rv += ht
         rv += ("\n# -------- end %d:%d response ----------\n"

Modified: libcloud/branches/0.11.x/libcloud/storage/drivers/s3.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.11.x/libcloud/storage/drivers/s3.py?rev=1411019&r1=1411018&r2=1411019&view=diff
==============================================================================
--- libcloud/branches/0.11.x/libcloud/storage/drivers/s3.py (original)
+++ libcloud/branches/0.11.x/libcloud/storage/drivers/s3.py Sun Nov 18 23:25:40 2012
@@ -199,9 +199,6 @@ class S3StorageDriver(StorageDriver):
         return container
 
     def get_object(self, container_name, object_name):
-        # TODO: Figure out what is going on when the object or container
-        # does not exist- it seems that Amazon just keeps the connection open
-        # and doesn't return a response.
         container = self.get_container(container_name=container_name)
         response = self.connection.request('/%s/%s' % (container_name,
                                                        object_name),