Discussion:
[libtorrent] Python, download speed limit for all torrent
Mircea Stanciu
2016-08-29 11:36:20 UTC
Permalink
Continuing from here,
https://sourceforge.net/p/libtorrent/mailman/message/35312277/


My Raspberry can't handle download speeds higher than 300kbps. Here is
the client code I am using:


import libtorrent as lt
import time, os

torrent_path = '/home/torrent'

ses = lt.session()

ses.listen_on(6881, 6891)
session_settings = ses.settings()
session_settings.download_rate_limit = 300 * 1000
ses.set_settings(session_settings)

for file in os.listdir(torrent_path):
le_file = torrent_path + '/' + file
print le_file
e = lt.bdecode(open(le_file, 'rb').read())
info = lt.torrent_info(e)
h = ses.add_torrent(info, "/home/Downloads")

while (not h.is_seed()):
s = h.status()

state_str = ['queued', 'checking', 'downloading metadata', \
'downloading', 'finished', 'seeding',
'allocating', 'checking fastresume']

print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s
peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000,
s.upload_rate / 1000, \
s.num_peers, state_str[s.state])

time.sleep(1)

print 'end of while, moving to next torrent in folder'

My problem now is with the "download_rate_limit" setting. If I run the
script the first torrent downloads at the set rate, but the next ones
will ignore this setting, reaching 10 MB/s and overwhelming the disk.


Why is "session_settings.download_rate_limit = 300 * 1000" affecting
only the first torrent? I tried moving the "ses.set_settings" inside the
for loop and even deleting the "ses" object at the end of the while loop
and declaring a new one with every pass trough the for loop, but nothing
changed.


Any suggestions?

Kind regards,

Mircea



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
M***@massaroddel.de
2016-08-29 16:18:11 UTC
Permalink
Post by Mircea Stanciu
Continuing from here,
https://sourceforge.net/p/libtorrent/mailman/message/35312277/
My Raspberry can't handle download speeds higher than 300kbps. Here is
import libtorrent as lt
import time, os
torrent_path = '/home/torrent'
ses = lt.session()
ses.listen_on(6881, 6891)
session_settings = ses.settings()
session_settings.download_rate_limit = 300 * 1000
ses.set_settings(session_settings)
le_file = torrent_path + '/' + file
print le_file
e = lt.bdecode(open(le_file, 'rb').read())
info = lt.torrent_info(e)
h = ses.add_torrent(info, "/home/Downloads")
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', \
'downloading', 'finished', 'seeding',
'allocating', 'checking fastresume']
print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s
peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000,
s.upload_rate / 1000, \
s.num_peers, state_str[s.state])
time.sleep(1)
print 'end of while, moving to next torrent in folder'
My problem now is with the "download_rate_limit" setting. If I run the
script the first torrent downloads at the set rate, but the next ones
will ignore this setting, reaching 10 MB/s and overwhelming the disk.
Why is "session_settings.download_rate_limit = 300 * 1000" affecting
only the first torrent? I tried moving the "ses.set_settings" inside the
for loop and even deleting the "ses" object at the end of the while loop
and declaring a new one with every pass trough the for loop, but nothing
changed.
Any suggestions?
Try to disable UTP because it is not rate limited (anymore).

MassaRoddel

------------------------------------------------------------------------------
Angel Leon
2016-08-29 18:25:19 UTC
Permalink
is your issue ocurring during the same run, or after restarting the program?

I'm just wondering if you're using save_resume_data when you shutdown,
otherwise if the torrent starts again and it can't find the previous
download_rate_limit setting for the torrent it will set the
download_rate_limit to unlimited
<https://github.com/arvidn/libtorrent/blob/c05e29c48e6cc4878eafa4f84d4c87d18feb6627/src/read_resume_data.cpp#L131>
.

As for new torrents, when creating the add_torrent_params object, I'd set
the download limit on it by reading the value previously set on the session.
Post by M***@massaroddel.de
Post by Mircea Stanciu
Continuing from here,
https://sourceforge.net/p/libtorrent/mailman/message/35312277/
My Raspberry can't handle download speeds higher than 300kbps. Here is
import libtorrent as lt
import time, os
torrent_path = '/home/torrent'
ses = lt.session()
ses.listen_on(6881, 6891)
session_settings = ses.settings()
session_settings.download_rate_limit = 300 * 1000
ses.set_settings(session_settings)
le_file = torrent_path + '/' + file
print le_file
e = lt.bdecode(open(le_file, 'rb').read())
info = lt.torrent_info(e)
h = ses.add_torrent(info, "/home/Downloads")
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', \
'downloading', 'finished', 'seeding',
'allocating', 'checking fastresume']
print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s
peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000,
s.upload_rate / 1000, \
s.num_peers, state_str[s.state])
time.sleep(1)
print 'end of while, moving to next torrent in folder'
My problem now is with the "download_rate_limit" setting. If I run the
script the first torrent downloads at the set rate, but the next ones
will ignore this setting, reaching 10 MB/s and overwhelming the disk.
Why is "session_settings.download_rate_limit = 300 * 1000" affecting
only the first torrent? I tried moving the "ses.set_settings" inside the
for loop and even deleting the "ses" object at the end of the while loop
and declaring a new one with every pass trough the for loop, but nothing
changed.
Any suggestions?
Try to disable UTP because it is not rate limited (anymore).
MassaRoddel
------------------------------------------------------------------------------
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
------------------------------------------------------------------------------
Mircea Stanciu
2016-08-31 06:52:42 UTC
Permalink
I am testing on local network (tracker and client).
Post by Angel Leon
Post by M***@massaroddel.de
download_rate_limit = someNumber
local_download_rate_limit = someNumber
ignore_limits_on_local_network = False
rate_limit_utp = False
With this the download speed gets limited, but with the sum of
(download_rate_limit+local_download_rate_limit). If download_rate_limit
is set to 75kb and local_download_rate_limit is set to 50kb my torrent
will download with a max of 75+50 (125kbps).
Post by Angel Leon
is your issue ocurring during the same run, or after restarting the program?
I'm just wondering if you're using save_resume_data when you shutdown,
otherwise if the torrent starts again and it can't find the previous
download_rate_limit setting for the torrent it will set the
download_rate_limit to unlimited
<https://github.com/arvidn/libtorrent/blob/c05e29c48e6cc4878eafa4f84d4c87d18feb6627/src/read_resume_data.cpp#L131>
.
As for new torrents, when creating the add_torrent_params object, I'd set
the download limit on it by reading the value previously set on the session.
Post by M***@massaroddel.de
Continuing from here,
https://sourceforge.net/p/libtorrent/mailman/message/35312277/
My Raspberry can't handle download speeds higher than 300kbps. Here is
import libtorrent as lt
import time, os
torrent_path = '/home/torrent'
ses = lt.session()
ses.listen_on(6881, 6891)
session_settings = ses.settings()
session_settings.download_rate_limit = 300 * 1000
ses.set_settings(session_settings)
le_file = torrent_path + '/' + file
print le_file
e = lt.bdecode(open(le_file, 'rb').read())
info = lt.torrent_info(e)
h = ses.add_torrent(info, "/home/Downloads")
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', \
'downloading', 'finished', 'seeding',
'allocating', 'checking fastresume']
print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s
peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000,
s.upload_rate / 1000, \
s.num_peers, state_str[s.state])
time.sleep(1)
print 'end of while, moving to next torrent in folder'
My problem now is with the "download_rate_limit" setting. If I run the
script the first torrent downloads at the set rate, but the next ones
will ignore this setting, reaching 10 MB/s and overwhelming the disk.
Why is "session_settings.download_rate_limit = 300 * 1000" affecting
only the first torrent? I tried moving the "ses.set_settings" inside the
for loop and even deleting the "ses" object at the end of the while loop
and declaring a new one with every pass trough the for loop, but nothing
changed.
Any suggestions?
Try to disable UTP because it is not rate limited (anymore).
MassaRoddel
------------------------------------------------------------------------------
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
------------------------------------------------------------------------------
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
--
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
------------------------------------------------------------------------------
Loading...