expose post_dht_stats() to python binding

This commit is contained in:
arvidn 2018-03-17 12:35:36 +01:00 committed by Arvid Norberg
parent 0edb0f28c1
commit 137baa6c04
3 changed files with 17 additions and 0 deletions

View File

@ -1,4 +1,5 @@
* expose post_dht_stats() to python binding
* fix backwards compatibility to downloads without partfiles
* improve part-file related error messages
* fix reporting &redundant= in tracker announces

View File

@ -900,6 +900,7 @@ void bind_session()
.def("outgoing_ports", &outgoing_ports)
#endif
.def("post_torrent_updates", allow_threads(&lt::session::post_torrent_updates), arg("flags") = 0xffffffff)
.def("post_dht_stats", allow_threads(&lt::session::post_dht_stats))
.def("post_session_stats", allow_threads(&lt::session::post_session_stats))
.def("is_listening", allow_threads(&lt::session::is_listening))
.def("listen_port", allow_threads(&lt::session::listen_port))

View File

@ -383,6 +383,21 @@ class test_session(unittest.TestCase):
self.assertTrue(isinstance(a.values, dict))
self.assertTrue(len(a.values) > 0)
def test_post_dht_stats(self):
s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, 'enable_dht': False})
s.post_dht_stats()
alerts = []
# first the stats headers log line. but not if logging is disabled
time.sleep(1)
alerts = s.pop_alerts()
a = alerts.pop(0)
while not isinstance(a, lt.dht_stats_alert):
a = alerts.pop(0
)
self.assertTrue(isinstance(a, lt.dht_stats_alert))
self.assertTrue(isinstance(a.active_requests, list))
self.assertTrue(isinstance(a.routing_table, list))
def test_unknown_settings(self):
try:
s = lt.session({'unexpected-key-name': 42})