Exemplo n.º 1
0
 def read(self, req, size, off, file_info):
     log("read(%s)" % size)
     global buffer, threads
     if not threads:
         log("Creating %d threads" % self.num_threads)
         for i, t in enumerate(range(self.num_threads)):
             thread = RandomDataFetcher(i)
             thread.setDaemon(True)
             thread.start()
             threads.append(thread)
     data = ''
     while len(data) < size:
         try:
             data += buffer.pop(0)
             break
         except IndexError:
             log("no data")
             time.sleep(0.1)
             continue
     if len(data) > size:
         buffer.append(data[size:])
         data = data[:size]
     libcuse.fuse_reply_buf(req, data, len(data))
Exemplo n.º 2
0
 def read(self, req, size, off, file_info):
     log("read(%s)" % size)
     global buffer, threads
     if not threads:
         log("Creating %d threads" % self.num_threads)
         for i, t in enumerate(list(range(self.num_threads))):
             thread = RandomDataFetcher(i)
             thread.setDaemon(True)
             thread.start()
             threads.append(thread)
     data = six.b('')
     while len(data) < size:
         try:
             data += buffer.pop(0)
             break
         except IndexError:
             log("no data")
             time.sleep(0.1)
             continue
     if len(data) > size:
         buffer.append(data[size:])
         data = data[:size]
     libcuse.fuse_reply_buf(req, data, len(data))
Exemplo n.º 3
0
 def read(self, req, size, off, file_info):
   out = self.input_buffer[off:size]
   print ("read size: %s off: %s reply: %s buffer: %s" % (
     size, off, len(out), len(self.input_buffer)))
   libcuse.fuse_reply_buf(req, self.input_buffer[off:size], len(out))
   self.input_buffer=self.input_buffer[off+size+1:]