# Buggy code
def _task_select_tracker(self):
    """
    The regularly scheduled task that selects torrents associated with a specific tracker to check.
    """

    # update the torrent selection interval
    self._reschedule_tracker_select()

    # start selecting torrents
    result = self.tribler_session.lm.tracker_manager.get_next_tracker_for_auto_check()
    if result is None:
        self._logger.warn("No tracker to select from, skip")
        return succeed(None)

    tracker_url, _ = result
    self._logger.debug("Start selecting torrents on tracker %s.", tracker_url)

    # get the torrents that should be checked
    infohashes = self._torrent_db.getTorrentsOnTracker(tracker_url, int(time.time()))

    if len(infohashes) == 0:
        # We have not torrent to recheck for this tracker. Still update the last_check for this tracker.
        self._logger.info("No torrent to check for tracker %s", tracker_url)
        self.tribler_session.lm.tracker_manager.update_tracker_info(tracker_url, True)
        return succeed(None)
    elif (
        tracker_url != "DHT"
        and tracker_url != "no-DHT"
        and self.tribler_session.lm.tracker_manager.should_check_tracker(tracker_url)
    ):
        session = self._create_session_for_request(tracker_url, timeout=30)
        for infohash in infohashes:
            session.add_infohash(infohash)

        self._logger.info(
            "Selected %d new torrents to check on tracker: %s",
            len(infohashes),
            tracker_url,
        )
        return (
            session.connect_to_tracker()
            .addCallbacks(*self.get_callbacks_for_session(session))
            .addErrback(lambda _: None)
        )


# Traceback (RuntimeError)
Traceback (most recent call last):
File "TriblerGUI\core_manager.py", line 128, in on_received_state
RuntimeError: Unhandled Error
Traceback (most recent call last):
File "lib\multiprocessing\process.py", line 114, in run

File "TriblerGUI\core_manager.py", line 61, in start_tribler_core

File "lib\site-packages\twisted\internet\base.py", line 1195, in run

File "lib\site-packages\twisted\internet\base.py", line 1204, in mainLoop

--- <exception caught here> ---
File "lib\site-packages\twisted\internet\base.py", line 825, in runUntilCurrent

File "Tribler\Core\TorrentChecker\torrent_checker.py", line 119, in _task_select_tracker

File "Tribler\Core\TorrentChecker\torrent_checker.py", line 225, in _create_session_for_request

File "Tribler\Core\TorrentChecker\session.py", line 47, in create_tracker_session

File "Tribler\Core\Utilities\tracker_utils.py", line 110, in parse_tracker_url

exceptions.RuntimeError: No port number for UDP tracker URL.

# Fixed code
def _task_select_tracker(self):
    """
    The regularly scheduled task that selects torrents associated with a specific tracker to check.
    """

    # update the torrent selection interval
    self._reschedule_tracker_select()

    # start selecting torrents
    result = self.tribler_session.lm.tracker_manager.get_next_tracker_for_auto_check()
    if result is None:
        self._logger.warn("No tracker to select from, skip")
        return succeed(None)

    tracker_url, _ = result
    self._logger.debug("Start selecting torrents on tracker %s.", tracker_url)

    # get the torrents that should be checked
    infohashes = self._torrent_db.getTorrentsOnTracker(tracker_url, int(time.time()))

    if len(infohashes) == 0:
        # We have not torrent to recheck for this tracker. Still update the last_check for this tracker.
        self._logger.info("No torrent to check for tracker %s", tracker_url)
        self.tribler_session.lm.tracker_manager.update_tracker_info(tracker_url, True)
        return succeed(None)
    elif (
        tracker_url != "DHT"
        and tracker_url != "no-DHT"
        and self.tribler_session.lm.tracker_manager.should_check_tracker(tracker_url)
    ):
        try:
            session = self._create_session_for_request(tracker_url, timeout=30)
        except MalformedTrackerURLException as e:
            self._logger.error(e)
            return succeed(None)

        for infohash in infohashes:
            session.add_infohash(infohash)

        self._logger.info(
            "Selected %d new torrents to check on tracker: %s",
            len(infohashes),
            tracker_url,
        )
        return (
            session.connect_to_tracker()
            .addCallbacks(*self.get_callbacks_for_session(session))
            .addErrback(lambda _: None)
        )