本文整理汇总了Python中BaseLib.Core.BitTornado.BT1.PiecePicker.PiecePicker.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python PiecePicker.__init__方法的具体用法?Python PiecePicker.__init__怎么用?Python PiecePicker.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseLib.Core.BitTornado.BT1.PiecePicker.PiecePicker
的用法示例。
在下文中一共展示了PiecePicker.__init__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from BaseLib.Core.BitTornado.BT1.PiecePicker import PiecePicker [as 别名]
# 或者: from BaseLib.Core.BitTornado.BT1.PiecePicker.PiecePicker import __init__ [as 别名]
def __init__(
self,
numpieces,
rarest_first_cutoff=1,
rarest_first_priority_cutoff=3,
priority_step=20,
helper=None,
rate_predictor=None,
piecesize=0,
):
PiecePicker.__init__(
self, numpieces, rarest_first_cutoff, rarest_first_priority_cutoff, priority_step, helper, rate_predictor
)
# maximum existing piece number, to avoid scanning beyond it in next()
self.maxhave = 0
# some statistics
self.stats = {}
self.stats["high"] = 0
self.stats["mid"] = 0
self.stats["low"] = 0
# playback module
self.transporter = None
# self.outstanding_requests contains (piece-id, begin,
# length):timestamp pairs for each outstanding request.
self.outstanding_requests = {}
# The playing_delay and buffering_delay give three values
# (min, max, offeset) in seconds.
#
# The min tells how long before the cancel policy is allowed
# to kick in. We can not expect to receive a piece instantly,
# so we have to wait this time before having a download speed
# estimation.
#
# The max tells how long before we cancel the request. The
# request may also be canceled because the chunk will not be
# completed given the current download speed.
#
# The offset gives a grace period that is taken into account
# when choosing to cancel a request. For instance, when the
# peer download speed is to low to receive the chunk within 10
# seconds, a grace offset of 15 would ensure that the chunk is
# NOT canceled (usefull while buffering)
self.playing_delay = (5, 20, -0.5)
self.buffering_delay = (7.5, 30, 10)