'Utility function to dump the messages in a queue to a file
NOTE: Page size must be < 10 else SQS errors'

def dump(self, file_name, page_size=10, vtimeout=10, sep='\n'):

    fp = open(file_name, 'wb')
    n = 0
    l = self.get_messages(page_size, vtimeout)
    while l:
        for m in l:
            fp.write(m.get_body())
            if sep:
                fp.write(sep)
            n += 1
        l = self.get_messages(page_size, vtimeout)
    fp.close()
    return n
