예제 #1
0
    def initialize(self):
        # Start upnp
        self.get_session().start_upnp()

        if has_bep33_support():
            # Also listen to DHT log notifications - we need the dht_pkt_alert and extract the BEP33 bloom filters
            dht_health_session = self.get_session(
                self.tribler_session.config.get_default_number_hops())
            dht_health_session.set_alert_mask(
                self.default_alert_mask
                | lt.alert.category_t.dht_log_notification)
            self.dht_health_manager = DHTHealthManager(dht_health_session)

        # Make temporary directory for metadata collecting through DHT
        self.metadata_tmpdir = mkdtemp(suffix='tribler_metainfo_tmpdir')

        # Register tasks
        self.register_task("process_alerts",
                           self._task_process_alerts,
                           interval=1)
        if self.dht_readiness_timeout > 0:
            self._dht_ready_task = self.register_task("check_dht_ready",
                                                      self._check_dht_ready)
        self.register_task("request_torrent_updates",
                           self._request_torrent_updates,
                           interval=1)
        self.register_task('task_cleanup_metacache',
                           self._task_cleanup_metainfo_cache,
                           interval=60,
                           delay=0)

        self.set_download_states_callback(self.sesscb_states_callback)
예제 #2
0
    async def setUp(self):
        await super(TestDHTHealthManager, self).setUp()

        self.mock_lt_session = MockObject()
        self.mock_lt_session.dht_get_peers = lambda _: None

        self.dht_health_manager = DHTHealthManager(self.mock_lt_session)
예제 #3
0
async def dht_health_manager(session):
    session.dht_get_peers = lambda _: None
    manager = DHTHealthManager(session)
    yield manager
    await manager.shutdown_task_manager()