I want to implement a download speed limit with urllib/urllib2. The basic idea is to look at how much was downloaded in the past x seconds and if it is above the limit, the script simply sleeps for some time.
Now the question is, what happens if you have an open connection (with urlopen()
), but don't call the read()
function for a while?
- Does urllib have a built-in buffer that downloads until the buffer is full and every time you call
read()
, the buffer is reduced by n bytes and the download continues (and obviously if it is full, urllib waits)? - If there is a urllib buffer, how big is it, and can one set the size manually?
- If there is no buffer, does urllib simply continue to download?
- Is there a difference between urllib and urllib2
read()
function or are they the same?