bittorrent - Downloading a Torrent with libtorrent-python -


i have following python code:

import libtorrent lt import time  ses = lt.session() ses.listen_on(6881, 6891) params = {     'save_path': '/home/downloads/',     'storage_mode': lt.storage_mode_t(2),     'paused': false,     'auto_managed': true,     'duplicate_is_error': true} link = "magnet:?xt=urn:btih:4mr6hu7sihxaxqqfxfjtnltysredr5ei&tr=http://tracker.vodo.net:6970/announce" handle = lt.add_magnet_uri(ses, link, params) ses.start_dht()  print 'downloading metadata...' while (not handle.has_metadata()):     time.sleep(1) print 'got metadata, starting torrent download...' while (handle.status().state != lt.torrent_status.seeding):     s = handle.status()     state_str = ['queued', 'checking', 'downloading metadata', \                 'downloading', 'finished', 'seeding', 'allocating']     print '%.2f%% complete (down: %.1f kb/s up: %.1f kb/s peers: %d) %s %.3' % \                 (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \                 s.num_peers, state_str[s.state], s.total_download/1000000)     time.sleep(5) 

which seems work fine, slows down less byte/s:

$ python test.py  downloading metadata... got metadata, starting torrent download... 0.00% complete (down: 195.0 kb/s up: 8.0 kb/s peers: 28) checking 3.069 0.00% complete (down: 133.0 kb/s up: 5.0 kb/s peers: 28) checking 3.342 0.00% complete (down: 29.0 kb/s up: 1.0 kb/s peers: 28) checking 3.359 0.00% complete (down: 5.0 kb/s up: 0.0 kb/s peers: 28) checking 3.398 0.00% complete (down: 4.0 kb/s up: 0.0 kb/s peers: 28) checking 3.401 0.00% complete (down: 0.0 kb/s up: 0.0 kb/s peers: 28) checking 3.405 0.00% complete (down: 0.0 kb/s up: 0.0 kb/s peers: 28) checking 3.408 0.00% complete (down: 0.0 kb/s up: 0.0 kb/s peers: 28) checking 3.412 

it slows down , never completes. idea why happens?

the problem turned out trivial. save_path did not exist, libtorrent library downloaded long did not have flush cache, once attempted write file, failed , not continue downloading, therefore slowdown , eventual halt. once existing path added worked fine.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -