當前位置: 首頁>>代碼示例>>Python>>正文


Python PiecePicker.PiecePicker類代碼示例

本文整理匯總了Python中Tribler.Core.BitTornado.BT1.PiecePicker.PiecePicker的典型用法代碼示例。如果您正苦於以下問題:Python PiecePicker類的具體用法?Python PiecePicker怎麽用?Python PiecePicker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PiecePicker類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: got_have

    def got_have(self, piece, connection=None):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: got_have:",piece
        self.maxhave = max(self.maxhave,piece)
        PiecePicker.got_have( self, piece, connection )
        if self.transporter:
            self.transporter.got_have( piece )

        if self.is_interesting(piece):
            self.peer_connections[connection]["interesting"][piece] = 1
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:10,代碼來源:PiecePickerSVC.py

示例2: got_have

    def got_have(self, piece, connection=None):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: got_have:",piece
        self.maxhave = max(self.maxhave,piece)

        # Arno, 2010-04-15: STBSPEED Disabled, does nothing but stats.
        #if self.transporter:
        #    self.transporter.got_have( piece )
        PiecePicker.got_have(self,piece,connection)

        if self.is_interesting(piece):
            self.peer_connections[connection]["interesting"][piece] = 1
開發者ID:egbertbouman,項目名稱:tribler-g,代碼行數:12,代碼來源:PiecePickerStreaming.py

示例3: complete

    def complete(self, piece):
        # if DEBUG:
        #     print >>sys.stderr,"PiecePickerStreaming: complete:",piece
        PiecePicker.complete( self, piece )
        if self.transporter:
            self.transporter.complete( piece )

        for request in self.outstanding_requests.keys():
            if request[0] == piece:
                del self.outstanding_requests[request]

        # don't consider this piece anymore
        for d in self.peer_connections.itervalues():
            d["interesting"].pop(piece,0)
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:14,代碼來源:PiecePickerSVC.py

示例4: complete

    def complete(self, piece):
        if DEBUG:
            print >>sys.stderr,"PiecePickerStreaming: complete:",piece
        PiecePicker.complete( self, piece )
        if self.transporter:
            self.transporter.complete( piece )
        try:
            del self.outstanding[piece]
        except:
            pass

        # don't consider this piece anymore
        for d in self.peer_connections.itervalues():
            d["interesting"].pop(piece,0)
開發者ID:nomadsummer,項目名稱:cs198mojo,代碼行數:14,代碼來源:PiecePickerStreaming.py

示例5: get_valid_range_iterator

 def get_valid_range_iterator(self):
     if self.videostatus.live_streaming and self.videostatus.get_live_startpos() is None:
         # Not hooked in, so cannot provide a sensible download range
         #print >>sys.stderr,time.asctime(),'-', "PiecePickerStreaming: Not hooked in, valid range set to total"
         return PiecePicker.get_valid_range_iterator(self)
         
     #print >>sys.stderr,time.asctime(),'-', "PiecePickerStreaming: Live hooked in, or VOD, valid range set to subset"
     first,last = self.videostatus.download_range()
     return self.videostatus.generate_range((first,last))
開發者ID:Anaconda84,項目名稱:Anaconda,代碼行數:9,代碼來源:PiecePickerStreaming.py

示例6: __init__

    def __init__(self, numpieces,
                 rarest_first_cutoff = 1, rarest_first_priority_cutoff = 3,
                 priority_step = 20, piecesize = 0):
        PiecePicker.__init__( self, numpieces, rarest_first_cutoff, rarest_first_priority_cutoff,
                              priority_step)

        # 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 too low to receive the chunk within 10
        # seconds, a grace offset of 15 would ensure that the chunk is
        # NOT canceled (useful while buffering)
        self.playing_delay = (5, 20, -0.5)
        self.buffering_delay = (7.5, 30, 10)

        # Arno, 2010-04-20: STBSPEED: is_interesting is now a variable.
        self.is_interesting  = self.is_interesting_normal
開發者ID:egbertbouman,項目名稱:tribler-g,代碼行數:44,代碼來源:PiecePickerStreaming.py

示例7: __init__

    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 )

        self.videostatus = None

        # 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

        # video speed in bytes/s
        self.outstanding = {}
        
        # Piece timeout policy parameters
        """
        minprebufspeed = 10.0 # KB/s
        self.PIECETIME = piecesize/(minprebufspeed*1024.0)
        self.MAXDLTIME=2.0*self.PIECETIME 
        self.MAXDLTIME_NONPREBUF=4.0*self.PIECETIME
        """
        # Works for 32KB pieces, like vuze.com
        self.PIECETIME = 10.0
        self.MAXDLTIME = 20.0
        self.MAXDLTIME_NONPREBUF=30.0

        """
開發者ID:nomadsummer,項目名稱:cs198mojo,代碼行數:36,代碼來源:PiecePickerStreaming.py

示例8: next

    def next(self, haves, wantfunc, sdownload, complete_first = False, slowpieces=[], willrequest=True,connection=None):
        def newwantfunc( piece ):
            #print >>sys.stderr,"S",self.streaming_piece_filter( piece ),"!sP",not (piece in slowpieces),"w",wantfunc( piece )
            return not (piece in slowpieces) and wantfunc( piece )

        # fallback: original piece picker
        p = PiecePicker.next(self, haves, newwantfunc, sdownload, complete_first, slowpieces=slowpieces, willrequest=willrequest,connection=connection)
        if DEBUGPP and self.videostatus.prebuffering:
            print >>sys.stderr,"PiecePickerStreaming: original PP.next returns",p
        if p is None and not self.videostatus.live_streaming:
            # When the file we selected from a multi-file torrent is complete,
            # we won't request anymore pieces, so the normal way of detecting 
            # we're done is not working and we won't tell the video player 
            # we're playable. Do it here instead.
            self.transporter.notify_playable()
        return p
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:16,代碼來源:PiecePickerSVC.py

示例9: requested

 def requested(self, *request):
     self.outstanding_requests[request] = time.time()
     return PiecePicker.requested(self, *request)
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:3,代碼來源:PiecePickerSVC.py

示例10: lost_peer

 def lost_peer(self, connection):
     PiecePicker.lost_peer( self, connection )
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:2,代碼來源:PiecePickerSVC.py

示例11: got_peer

    def got_peer(self, connection):
        PiecePicker.got_peer( self, connection )

        self.peer_connections[connection]["interesting"] = {}
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:4,代碼來源:PiecePickerSVC.py

示例12: lost_have

 def lost_have(self, piece):
     PiecePicker.lost_have( self, piece )
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:2,代碼來源:PiecePickerSVC.py

示例13: got_seed

 def got_seed(self):
     self.maxhave = self.numpieces
     PiecePicker.got_seed( self )
開發者ID:ebcayabyab-personal,項目名稱:swiftarm,代碼行數:3,代碼來源:PiecePickerSVC.py


注:本文中的Tribler.Core.BitTornado.BT1.PiecePicker.PiecePicker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。