forked from LBRYCommunity/lbry-sdk
removed runner.shutdown() as runner.cleanup() calls this already
This commit is contained in:
parent
ba48713219
commit
1ed38fff6f
5 changed files with 10 additions and 11 deletions
|
@ -276,6 +276,7 @@ def run_daemon(args: argparse.Namespace, conf: Config):
|
|||
pass
|
||||
finally:
|
||||
loop.run_until_complete(daemon.stop())
|
||||
logging.shutdown()
|
||||
|
||||
if hasattr(loop, 'shutdown_asyncgens'):
|
||||
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||
|
|
|
@ -466,18 +466,13 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
self.component_startup_task = asyncio.create_task(self.component_manager.start())
|
||||
await self.component_startup_task
|
||||
|
||||
async def stop(self, shutdown_runner=True):
|
||||
async def stop(self):
|
||||
if self.component_startup_task is not None:
|
||||
if self.component_startup_task.done():
|
||||
await self.component_manager.stop()
|
||||
else:
|
||||
self.component_startup_task.cancel()
|
||||
log.info("stopped api components")
|
||||
if shutdown_runner:
|
||||
self.rpc_runner.app.on_shutdown.freeze()
|
||||
self.streaming_runner.app.on_shutdown.freeze()
|
||||
await self.rpc_runner.shutdown()
|
||||
await self.streaming_runner.shutdown()
|
||||
await self.rpc_runner.cleanup()
|
||||
await self.streaming_runner.cleanup()
|
||||
log.info("stopped api server")
|
||||
|
|
|
@ -69,7 +69,11 @@ class HTTPSLogglyHandler(logging.Handler):
|
|||
|
||||
def close(self):
|
||||
super().close()
|
||||
asyncio.create_task(self._session.close())
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(self._session.close())
|
||||
except RuntimeError:
|
||||
pass
|
||||
|
||||
|
||||
def get_loggly_handler():
|
||||
|
|
|
@ -11,6 +11,7 @@ from lbry.extras.daemon.Components import (
|
|||
)
|
||||
from lbry.extras.daemon.Daemon import Daemon
|
||||
|
||||
|
||||
class CLIIntegrationTest(AsyncioTestCase):
|
||||
|
||||
async def asyncSetUp(self):
|
||||
|
@ -26,9 +27,7 @@ class CLIIntegrationTest(AsyncioTestCase):
|
|||
Daemon.component_attributes = {}
|
||||
self.daemon = Daemon(conf)
|
||||
await self.daemon.start()
|
||||
|
||||
async def asyncTearDown(self):
|
||||
await self.daemon.stop(shutdown_runner=False)
|
||||
self.addCleanup(self.daemon.stop)
|
||||
|
||||
def test_cli_status_command_with_auth(self):
|
||||
actual_output = StringIO()
|
||||
|
|
|
@ -5,9 +5,9 @@ import contextlib
|
|||
import logging
|
||||
from io import StringIO
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
from types import SimpleNamespace
|
||||
from contextlib import asynccontextmanager
|
||||
from unittest.mock import patch
|
||||
|
||||
import docopt
|
||||
from torba.testcase import AsyncioTestCase
|
||||
|
|
Loading…
Reference in a new issue