MCPcopy Index your code
hub / github.com/pyload/pyload / writeBody

Method writeBody

module/network/HTTPChunk.py:225–258  ·  view source on GitHub ↗
(self, buf)

Source from the content-addressed store, hash-verified

223 return None #:All is fine
224
225 def writeBody(self, buf):
226 #:Ignore BOM, it confuses unrar
227 if not self.BOMChecked:
228 if buf[:3] == codecs.BOM_UTF8:
229 buf = buf[3:]
230 self.BOMChecked = True
231
232 size = len(buf)
233
234 self.arrived += size
235
236 self.fp.write(buf)
237
238 if self.p.bucket:
239 time.sleep(self.p.bucket.consumed(size))
240
241 else:
242 # Avoid small buffers, increasing sleep time slowly if buffer size gets smaller
243 # otherwise reduce sleep time percentual (values are based on tests)
244 # So in general cpu time is saved without reducing bandwith too much
245
246 if size < self.lastSize:
247 self.sleep += 0.002
248 else:
249 self.sleep *= 0.7
250
251 self.lastSize = size
252
253 time.sleep(self.sleep)
254
255 if self.range and self.arrived > self.size:
256 return 0 #:Close if we have enough data
257
258 return None #:All is fine
259
260 def parseHeader(self):
261 """parse data from recieved header"""

Callers

nothing calls this directly

Calls 3

consumedMethod · 0.80
writeMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected