# Buggy code
def tribler_started(self):
    async def signal_handler(sig):
        print(f"Received shut down signal {sig}")
        if not self._stopping:
            self._stopping = True
            await self.session.shutdown()
            get_event_loop().stop()

    signal.signal(signal.SIGINT, lambda sig, _: ensure_future(signal_handler(sig)))
    signal.signal(signal.SIGTERM, lambda sig, _: ensure_future(signal_handler(sig)))

    self.register_task(
        "bootstrap", self.session.tunnel_community.bootstrap, interval=30
    )

    # Remove all logging handlers
    root_logger = logging.getLogger()
    handlers = root_logger.handlers
    for handler in handlers:
        root_logger.removeHandler(handler)
    logging.getLogger().setLevel(logging.ERROR)

    new_strategies = []
    with self.session.ipv8.overlay_lock:
        for strategy, target_peers in self.session.ipv8.strategies:
            if strategy.overlay == self.session.tunnel_community:
                new_strategies.append((strategy, -1))
            else:
                new_strategies.append((strategy, target_peers))
        self.session.ipv8.strategies = new_strategies


# Traceback (tribler_gui.event_request_manager.CoreConnectTimeoutError)
Traceback (most recent call last):
File "src\tribler-gui\tribler_gui\event_request_manager.py", line 138, in <lambda>
File "src\tribler-gui\tribler_gui\event_request_manager.py", line 80, in on_error
tribler_gui.event_request_manager.CoreConnectTimeoutError: Could not connect with the Tribler Core within 60 seconds
[PID:5376] 2020-08-25 15:41:08,656 - ERROR <session:366> Session.unhandled_error_observer(): Unhandled exception occurred! [Errno 10048] error while attempting to bind on address ('127.0.0.1', 8085): une seule utilisation de chaque adresse de socket (protocole/adresse r�seau/port) est habituellement autoris�e
--LONG TEXT--
Traceback (most recent call last):
File "src\run_tribler.py", line 81, in start_tribler
File "src\tribler-core\tribler_core\session.py", line 397, in start
File "src\tribler-core\tribler_core\restapi\rest_manager.py", line 77, in start
File "lib\site-packages\aiohttp\web_runner.py", line 100, in start
File "lib\asyncio\base_events.py", line 1463, in create_server
OSError: [Errno 10048] error while attempting to bind on address ('127.0.0.1', 8085): une seule utilisation de chaque adresse de socket (protocole/adresse r�seau/port) est habituellement autoris�e

--CONTEXT--
{'message': 'Task exception was never retrieved', 'exception': OSError(10048, "error while attempting to bind on address ('127.0.0.1', 8085): une seule utilisation de chaque adresse de socket (protocole/adresse r�seau/port) est habituellement autoris�e"), 'future': <Task finished name='Task-1' coro=<start_tribler_core.<locals>.start_tribler() done, defined at src\run_tribler.py:50> exception=OSError(10048, "error while attempting to bind on address ('127.0.0.1', 8085): une seule utilisation de chaque adresse de socket (protocole/adresse r�seau/port) est habituellement autoris�e")>}

# Fixed code
def tribler_started(self):
    async def signal_handler(sig):
        print(f"Received shut down signal {sig}")  # noqa: T001
        if not self._stopping:
            self._stopping = True
            await self.session.shutdown()
            get_event_loop().stop()

    signal.signal(signal.SIGINT, lambda sig, _: ensure_future(signal_handler(sig)))
    signal.signal(signal.SIGTERM, lambda sig, _: ensure_future(signal_handler(sig)))

    self.register_task(
        "bootstrap", self.session.tunnel_community.bootstrap, interval=30
    )

    # Remove all logging handlers
    root_logger = logging.getLogger()
    handlers = root_logger.handlers
    for handler in handlers:
        root_logger.removeHandler(handler)
    logging.getLogger().setLevel(logging.ERROR)

    new_strategies = []
    with self.session.ipv8.overlay_lock:
        for strategy, target_peers in self.session.ipv8.strategies:
            if strategy.overlay == self.session.tunnel_community:
                new_strategies.append((strategy, -1))
            else:
                new_strategies.append((strategy, target_peers))
        self.session.ipv8.strategies = new_strategies