'Method for a file PUT coroutine. Takes chunks from a queue and sends
them down a socket.
If something goes wrong, the "failed" attribute will be set to true
and the exception handler will be called.'

def _send_file(self, write_timeout, exception_handler):

    while True:
        chunk = self.queue.get()
        if (not self.failed):
            if self.chunked:
                to_send = ('%x\r\n%s\r\n' % (len(chunk), chunk))
            else:
                to_send = chunk
            try:
                with ChunkWriteTimeout(write_timeout):
                    self.conn.send(to_send)
            except (Exception, ChunkWriteTimeout):
                self.failed = True
                exception_handler(self.node, _('Object'), (_('Trying    to    write    to    %s') % self.path))
        self.queue.task_done()
