Skip to content

Commit

Permalink
Fixes Tribler#7216
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Dec 12, 2022
1 parent 4dbb10b commit e053c71
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/tribler/core/components/restapi/rest/rest_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import ssl
import traceback
from typing import Optional

from aiohttp import web
from aiohttp.web_exceptions import HTTPNotFound
Expand Down Expand Up @@ -73,9 +74,9 @@ def __init__(self, config: APISettings, root_endpoint: RootEndpoint, state_dir=N
super().__init__()
self._logger = logging.getLogger(self.__class__.__name__)
self.root_endpoint = root_endpoint
self.runner = None
self.site = None
self.site_https = None
self.runner: Optional[web.AppRunner] = None
self.site: Optional[web.TCPSite] = None
self.site_https: Optional[web.TCPSite] = None
self.config = config
self.state_dir = state_dir

Expand Down Expand Up @@ -152,14 +153,7 @@ async def start(self):
self._logger.info("Started HTTPS REST API: %s", self.site_https.name)

async def stop(self):
"""
Stop the HTTP API and return a deferred that fires when the server has shut down.
"""
self._logger.info('Stop')

if self.site:
await self.site.stop()
if self.site_https:
await self.site_https.stop()
# Should the next line be used instead of the above lines?
# await self.runner.cleanup()
if self.runner:
await self.runner.shutdown() # should be called before self.runner.cleanup()
await self.runner.cleanup() # self.site.stop() is called inside this method

0 comments on commit e053c71

Please sign in to comment.