/usr/share/pyshared/glance/common/utils.py
Add __len__ and __getitem__ method to class CooperativeReader will make it work

class CooperativeReader(object):
    """
    An eventlet thread friendly class for reading in image data.

    When accessing data either through the iterator or the read method
    we perform a sleep to allow a co-operative yield. When there is more than
    one image being uploaded/downloaded this prevents eventlet thread
    starvation, ie allows all threads to be scheduled periodically rather than
    having the same thread be continuously active.
    """
    def __init__(self, fd):
        """
        :param fd: Underlying image file object
        """
        self.fd = fd
        if hasattr(fd, 'read'):
            self.read = cooperative_read(fd)

    def __iter__(self):
        return cooperative_iter(self.fd.__iter__())

    def __len__(self):
        return len(self.fd)

    def __getitem__(self, i):
        return self.fd.__getitem__(i)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1057322

Title:
  Image fails to upload to swift: TypeError: object of type
  'CooperativeReader' has no len(

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glance/+bug/1057322/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to