formatting
This commit is contained in:
@@ -11,8 +11,6 @@ from typing import Any, Callable
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class AppDaemonRunContext:
|
class AppDaemonRunContext:
|
||||||
_stack: ExitStack = field(default_factory=ExitStack)
|
_stack: ExitStack = field(default_factory=ExitStack)
|
||||||
@@ -28,7 +26,8 @@ class AppDaemonRunContext:
|
|||||||
|
|
||||||
signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT)
|
signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT)
|
||||||
for s in signals:
|
for s in signals:
|
||||||
self.loop.add_signal_handler(s, lambda s=s: self.loop.create_task(self.shutdown(s)))
|
self.loop.add_signal_handler(
|
||||||
|
s, lambda s=s: self.loop.create_task(self.shutdown(s)))
|
||||||
|
|
||||||
self.executor = self._stack.enter_context(self.thread_context())
|
self.executor = self._stack.enter_context(self.thread_context())
|
||||||
logger.debug("Started thread pool")
|
logger.debug("Started thread pool")
|
||||||
@@ -60,7 +59,8 @@ class AppDaemonRunContext:
|
|||||||
asyncio.wait_for(t, timeout=self.shutdown_grace_period)
|
asyncio.wait_for(t, timeout=self.shutdown_grace_period)
|
||||||
for t in tasks
|
for t in tasks
|
||||||
)
|
)
|
||||||
logger.debug(f'Allowing graceful shutdown from stop event for {self.shutdown_grace_period}s')
|
logger.debug(f'Allowing graceful shutdown from stop event for {
|
||||||
|
self.shutdown_grace_period}s')
|
||||||
await asyncio.gather(*graceful, return_exceptions=True)
|
await asyncio.gather(*graceful, return_exceptions=True)
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class ADSubsystem:
|
|||||||
if not self.stopping:
|
if not self.stopping:
|
||||||
await asyncio.sleep(delay)
|
await asyncio.sleep(delay)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
self.logger.debug('Cancelled during sleep')
|
self.logger.debug('Cancelled during sleep')
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user