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
|
pass
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(daemon.stop())
|
loop.run_until_complete(daemon.stop())
|
||||||
|
logging.shutdown()
|
||||||
|
|
||||||
if hasattr(loop, 'shutdown_asyncgens'):
|
if hasattr(loop, 'shutdown_asyncgens'):
|
||||||
loop.run_until_complete(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())
|
self.component_startup_task = asyncio.create_task(self.component_manager.start())
|
||||||
await self.component_startup_task
|
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 is not None:
|
||||||
if self.component_startup_task.done():
|
if self.component_startup_task.done():
|
||||||
await self.component_manager.stop()
|
await self.component_manager.stop()
|
||||||
else:
|
else:
|
||||||
self.component_startup_task.cancel()
|
self.component_startup_task.cancel()
|
||||||
log.info("stopped api components")
|
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.rpc_runner.cleanup()
|
||||||
await self.streaming_runner.cleanup()
|
await self.streaming_runner.cleanup()
|
||||||
log.info("stopped api server")
|
log.info("stopped api server")
|
||||||
|
|
|
@ -69,7 +69,11 @@ class HTTPSLogglyHandler(logging.Handler):
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
super().close()
|
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():
|
def get_loggly_handler():
|
||||||
|
|
|
@ -11,6 +11,7 @@ from lbry.extras.daemon.Components import (
|
||||||
)
|
)
|
||||||
from lbry.extras.daemon.Daemon import Daemon
|
from lbry.extras.daemon.Daemon import Daemon
|
||||||
|
|
||||||
|
|
||||||
class CLIIntegrationTest(AsyncioTestCase):
|
class CLIIntegrationTest(AsyncioTestCase):
|
||||||
|
|
||||||
async def asyncSetUp(self):
|
async def asyncSetUp(self):
|
||||||
|
@ -26,9 +27,7 @@ class CLIIntegrationTest(AsyncioTestCase):
|
||||||
Daemon.component_attributes = {}
|
Daemon.component_attributes = {}
|
||||||
self.daemon = Daemon(conf)
|
self.daemon = Daemon(conf)
|
||||||
await self.daemon.start()
|
await self.daemon.start()
|
||||||
|
self.addCleanup(self.daemon.stop)
|
||||||
async def asyncTearDown(self):
|
|
||||||
await self.daemon.stop(shutdown_runner=False)
|
|
||||||
|
|
||||||
def test_cli_status_command_with_auth(self):
|
def test_cli_status_command_with_auth(self):
|
||||||
actual_output = StringIO()
|
actual_output = StringIO()
|
||||||
|
|
|
@ -5,9 +5,9 @@ import contextlib
|
||||||
import logging
|
import logging
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
from unittest.mock import patch
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import docopt
|
import docopt
|
||||||
from torba.testcase import AsyncioTestCase
|
from torba.testcase import AsyncioTestCase
|
||||||
|
|
Loading…
Reference in a new issue