Package DebTorrent :: Package BT1 :: Module Rerequester :: Class Rerequester
[hide private]
[frames] | no frames]

Class Rerequester

source code

Communicate with a tracker.

Instance Methods [hide private]
 
__init__(self, port, myid, infohash, trackerlist, config, sched, externalsched, errorfunc, connect, howmany, amount_left, up, down, upratefunc, downratefunc, doneflag, unpauseflag=fakeflag(True), seededfunc=None, force_rapid_update=True)
Initialize the instance.
source code
 
start(self)
Start the tracker requester.
source code
 
c(self)
Start a periodic general announce request for more peers.
source code
 
_c(self)
Schedule another general announce request for more peers.
source code
 
d(self, event=3)
Start a periodic announce request.
source code
 
_d(self)
Schedule another announce request
source code
 
hit(self, event=3)
Start a specific type of announce request for more peers.
source code
 
announce(self, event=3, callback=<function <lambda> at 0x2b5519901c08>, specialurl=None)
Create an announce request.
source code
 
snoop(self, peers, callback=<function <lambda> at 0x2b5519901cf8>)
Send an immediate request to the tracker.
source code
 
rerequest(self, s, callback)
Start a threaded request to a tracker.
source code
 
_rerequest(self, s, callback)
Try all the trackers in the list for an announce request.
source code
 
_fail(self, callback)
Process the failed request.
source code
 
rerequest_single(self, t, s, callback)
Start a threaded request to a single tracker and wait for it to complete.
source code
 
_rerequest_single(self, t, s, l, callback)
Perform a request to a single tracker.
source code
 
postrequest(self, r, callback)
Process the returned request from a single tracker.
source code
Instance Variables [hide private]
method amount_left
method to call to determine how much is left to download
int announce_interval
the tracker-specified announce interval to use
method connect
method to call to start connections to new peers
threading.Event doneflag
the flag that indicates when the program is to be shutdown
method down
method to call to determine how much has been downloaded
method downratefunc
method to call to determine the current download rate
dictionary errorcodes
error codes and messages that have occurred
method errorfunc
method to call when an error occurs
method externalsched
method to call to schedule future invocation of other functions
boolean force_rapid_update
whether to do quick tracker updates when requested
method howmany
method to call to determine how many connections are open
int interval
minimum time to wait between requesting more peers
string ip
IP address to report to the tracker
unknown last
a tracker parameter
boolean last_failed
whether the last request was successful
string lastsuccessful
the last tracker address that was successfully contacted
SuccessLock lock
the locks to use to synchronize threaded tracker requests
int maxpeers
number of peers at which to stop initiating new connections
int minpeers
minimum number of peers to not do rerequesting
boolean never_succeeded
whether there has ever been a successful request
string rejectedmessage
the start of the error messages to use when a failure occurs
method sched
method to call to schedule future invocation of requester functions
method seededfunc
method to call if the tracker reports the torrent is seeded
string special
a special tracker announce address to send a single request to
boolean stopped
whether the download is stopped
int timeout
time to wait before assuming that a connection has timed out
unknown trackerid
a tracker parameter
list of list of string trackerlist
the trackers to connect to
threading.Event unpauseflag
the flag to unset to pause the download
method up
method to call to determine how much has been uploaded
method upratefunc
method to call to determine the current upload rate
string url
the query parameters to send to all trackers
Method Details [hide private]

__init__(self, port, myid, infohash, trackerlist, config, sched, externalsched, errorfunc, connect, howmany, amount_left, up, down, upratefunc, downratefunc, doneflag, unpauseflag=fakeflag(True), seededfunc=None, force_rapid_update=True)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • port (int) - port to connect to this peer on
  • myid (string) - the peer ID to use
  • infohash (string) - the info hash of the torrent being downloaded
  • trackerlist (list of list of string) - the trackers to connect to
  • config (dictionary) - the configuration parameters
  • sched (method) - method to call to schedule future invocation of requester functions
  • externalsched (method) - method to call to schedule future invocation of other functions
  • errorfunc (method) - method to call when an error occurs
  • connect (method) - method to call to start connections to new peers
  • howmany (method) - method to call to determine how many connections are open
  • amount_left (method) - method to call to determine how much is left to download
  • up (method) - method to call to determine how much has been uploaded
  • down (method) - method to call to determine how much has been downloaded
  • upratefunc (method) - method to call to determine the current upload rate
  • downratefunc (method) - method to call to determine the current download rate
  • doneflag (threading.Event) - the flag that indicates when the program is to be shutdown
  • unpauseflag (threading.Event) - the flag to unset to pause the download (optional, defaults to an always True dummy flag)
  • seededfunc (method) - method to call if the tracker reports the torrent is seeded (optional, defaults to not checking)
  • force_rapid_update (boolean) - whether to do quick tracker updates when requested (optional, defaults to False)

d(self, event=3)

source code 
Start a periodic announce request.
Parameters:
  • event (int) - the type of announce request to do (optional, defaults to 3):
       0 -- started
       1 -- completed
       2 -- stopped
       3 -- general announce
    

hit(self, event=3)

source code 
Start a specific type of announce request for more peers.
Parameters:
  • event (int) - the type of announce request to do (optional, defaults to 3):
       0 -- started
       1 -- completed
       2 -- stopped
       3 -- general announce
    

announce(self, event=3, callback=<function <lambda> at 0x2b5519901c08>, specialurl=None)

source code 
Create an announce request.
Parameters:
  • event (int) - the type of announce request to do (optional, defaults to 3):
       0 -- started
       1 -- completed
       2 -- stopped
       3 -- general announce
    
  • callback (method) - the method to call when the announce is complete (optional, defaults to doing nothing)
  • specialurl (string) - a special tracker announce address to send this request to (optional, defaults to the regular tracker list)

snoop(self, peers, callback=<function <lambda> at 0x2b5519901cf8>)

source code 

Send an immediate request to the tracker.

Tracker call support for the tracker-to-tracker communication.
Parameters:
  • peers (int) - the number of peers to request
  • callback (method) - the method to call when the announce is complete (optional, defaults to doing nothing)

rerequest(self, s, callback)

source code 

Start a threaded request to a tracker.

Uses the SuccessLock to make sure concurrent requests are not allowed.
Parameters:
  • s (string) - the query to add to the URL for the request
  • callback (method) - the method to call when the announce is complete

_rerequest(self, s, callback)

source code 
Try all the trackers in the list for an announce request.
Parameters:
  • s (string) - the query to add to the URL for the request
  • callback (method) - the method to call when the announce is complete

_fail(self, callback)

source code 
Process the failed request.
Parameters:
  • callback (method) - the method to call when the announce is complete

rerequest_single(self, t, s, callback)

source code 
Start a threaded request to a single tracker and wait for it to complete.
Parameters:
  • t (string) - the announce address of the tracker to contact
  • s (string) - the query to add to the URL for the request
  • callback (method) - the method to call when the announce is complete

_rerequest_single(self, t, s, l, callback)

source code 
Perform a request to a single tracker.
Parameters:
  • t (string) - the announce address of the tracker to contact
  • s (string) - the query to add to the URL for the request
  • l (long) - the current hold on the lock
  • callback (method) - the method to call when the announce is complete

postrequest(self, r, callback)

source code 
Process the returned request from a single tracker.
Parameters:
  • r (dictionary) - the bdecoded data returned by the tracker
  • callback (method) - the method to call when the request is complete