network.bandwidth
Module¶
Network bandwidth.
-
class
wpull.network.bandwidth.
BandwidthLimiter
(rate_limit)[source]¶ Bases:
wpull.network.bandwidth.BandwidthMeter
Bandwidth rate limit calculator.
-
class
wpull.network.bandwidth.
BandwidthMeter
(sample_size=20, sample_min_time=0.15, stall_time=5.0)[source]¶ Bases:
object
Calculates the speed of data transfer.
Parameters: - sample_size (int) – The number of samples for measuring the speed.
- sample_min_time (float) – The minimum duration between samples in seconds.
- stall_time (float) – The time in seconds to consider no traffic to be connection stalled.
-
bytes_transferred
¶ Return the number of bytes transferred
Returns: int
-
feed
(data_len, feed_time=None)[source]¶ Update the bandwidth meter.
Parameters: - data_len (int) – The number of bytes transfered since the last
call to
feed()
. - feed_time (float) – Current time.
- data_len (int) – The number of bytes transfered since the last
call to
-
num_samples
¶ Return the number of samples collected.
-
speed
()[source]¶ Return the current transfer speed.
Returns: The speed in bytes per second. Return type: int
-
stalled
¶ Return whether the connection is stalled.
Returns: bool