arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.26k stars 996 forks source link

AttributeError: 'session' object has no attribute 'set_settings' #7404

Open abhishek-das-gupta opened 1 year ago

abhishek-das-gupta commented 1 year ago

libtorrent version (or branch): 1.2.0 / boost 1.75.0

platform/architecture: RHEL 9.0

We upgraded libtorent from 1.1.5 to 1.2.0 and boost from 1.65.1 to 1.75.0. The prodcution code is failing when trying to use the function set_settings.
The codeblock below gives an idea of instrcutions we are using in the production code.

Python 3.9.10 (main, Sep 23 2022, 00:00:00) 
[GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libtorrent
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> a_session = libtorrent.session(flags = libtorrent.session_flags_t.add_default_plugins)
>>> 
>>> 
>>> 
>>> a_session.set_settings({})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'session' object has no attribute 'set_settings'
>>> type(a_session)
<class 'libtorrent.session'>

>>> dir(a_session)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'add_dht_node', 'add_dht_router', 'add_extension', 'add_port_mapping', 'add_torrent', 'apply_settings', 'async_add_torrent', 'create_peer_class', 'delete_peer_class', 'delete_port_mapping', 'dht_announce', 'dht_get_immutable_item', 'dht_get_mutable_item', 'dht_get_peers', 'dht_proxy', 'dht_put_immutable_item', 'dht_put_mutable_item', 'dht_state', 'download_rate_limit', 'find_torrent', 'get_cache_info', 'get_cache_status', 'get_dht_settings', 'get_ip_filter', 'get_pe_settings', 'get_peer_class', 'get_settings', 'get_torrents', 'global_peer_class_id', 'i2p_proxy', 'id', 'is_dht_running', 'is_listening', 'is_paused', 'listen_on', 'listen_port', 'load_state', 'local_download_rate_limit', 'local_peer_class_id', 'local_upload_rate_limit', 'max_connections', 'num_connections', 'outgoing_ports', 'pause', 'peer_proxy', 'pop_alerts', 'post_dht_stats', 'post_session_stats', 'post_torrent_updates', 'proxy', 'remove_torrent', 'reopen_map_ports', 'reopen_network_sockets', 'resume', 'save_state', 'set_alert_mask', 'set_alert_notify', 'set_alert_queue_size_limit', 'set_dht_proxy', 'set_dht_settings', 'set_download_rate_limit', 'set_i2p_proxy', 'set_ip_filter', 'set_local_download_rate_limit', 'set_local_upload_rate_limit', 'set_max_connections', 'set_max_half_open_connections', 'set_max_uploads', 'set_pe_settings', 'set_peer_class', 'set_peer_class_filter', 'set_peer_class_type_filter', 'set_peer_id', 'set_peer_proxy', 'set_proxy', 'set_severity_level', 'set_tracker_proxy', 'set_upload_rate_limit', 'set_web_seed_proxy', 'start_dht', 'start_lsd', 'start_natpmp', 'start_upnp', 'status', 'stop_dht', 'stop_lsd', 'stop_natpmp', 'stop_upnp', 'tcp', 'tcp_peer_class_id', 'tracker_proxy', 'udp', 'upload_rate_limit', 'wait_for_alert', 'web_seed_proxy']

>>> 'set_settings' in dir(a_session)
False

>>> quit()

Is there an api change in the libtorrent python binding for libtorrent.session ? Please suggest I am unable to find it from a quick search.

If yes, then what to use instead?

If not, then how to debug this?

Thanks!

abhishek-das-gupta commented 1 year ago

Reading the doc

You have some control over session configuration through the session::apply_settings() member function. To change one or more configuration options, create a settings_pack object and fill it with the settings to be set and pass it in to session::apply_settings().

I think I need to use session.apply_settings(). but it says I need to create a settings_pack object ? I am unable to do that.

What I did is as follows

settings = session.get_settings()
setttings[key1] = value1
.
.
.
session.apply_settings(settings)

Please suggest whether the above is correct or not.

abhishek-das-gupta commented 1 year ago

Hellok @arvidn any suggestions?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.