Resolved black formatting
from __future__ import absolute_import
from st2common.util.monkey_patch import monkey_patch
+
monkey_patch()
import os
@@ -28,9 +29,7 @@ from st2common import log as logging
from st2common.service_setup import teardown as common_teardown
from st2common.service_setup import setup as common_setup
-__all__ = [
- 'main'
-]
+__all__ = ["main"]
LOG = logging.getLogger(__name__)
@@ -46,23 +45,27 @@ def _setup_sigterm_handler():
def _setup():
- capabilities = {
- 'name': 'scheduler',
- 'type': 'passive'
- }
- common_setup(service='scheduler', config=config, setup_db=True, register_mq_exchanges=True,
- register_signal_handlers=True, service_registry=True, capabilities=capabilities)
+ capabilities = {"name": "scheduler", "type": "passive"}
+ common_setup(
+ service="scheduler",
+ config=config,
+ setup_db=True,
+ register_mq_exchanges=True,
+ register_signal_handlers=True,
+ service_registry=True,
+ capabilities=capabilities,
+ )
_setup_sigterm_handler()
def _run_scheduler():
- LOG.info('(PID=%s) Scheduler started.', os.getpid())
+ LOG.info("(PID=%s) Scheduler started.", os.getpid())
# Lazy load these so that decorator metrics are in place
from st2actions.scheduler import (
handler as scheduler_handler,
- entrypoint as scheduler_entrypoint
+ entrypoint as scheduler_entrypoint,
)
handler = scheduler_handler.get_handler()
@@ -73,14 +76,18 @@ def _run_scheduler():
try:
handler._cleanup_policy_delayed()
except Exception:
- LOG.exception('(PID=%s) Scheduler unable to perform migration cleanup.', os.getpid())
+ LOG.exception(
+ "(PID=%s) Scheduler unable to perform migration cleanup.", os.getpid()
+ )
# TODO: Remove this try block for _fix_missing_action_execution_id in v3.2.
# This is a temporary fix to auto-populate action_execution_id.
try:
handler._fix_missing_action_execution_id()
except Exception:
- LOG.exception('(PID=%s) Scheduler unable to populate action_execution_id.', os.getpid())
+ LOG.exception(
+ "(PID=%s) Scheduler unable to populate action_execution_id.", os.getpid()
+ )
try:
handler.start()
@@ -89,7 +96,7 @@ def _run_scheduler():
# Wait on handler first since entrypoint is more durable.
handler.wait() or entrypoint.wait()
except (KeyboardInterrupt, SystemExit):
- LOG.info('(PID=%s) Scheduler stopped.', os.getpid())
+ LOG.info("(PID=%s) Scheduler stopped.", os.getpid())
errors = False
@@ -97,19 +104,19 @@ def _run_scheduler():
handler.shutdown()
entrypoint.shutdown()
except:
- LOG.debug('Unable to shutdown scheduler.', exc_info=True)
+ LOG.debug("Unable to shutdown scheduler.", exc_info=True)
errors = True
if errors:
return 1
except:
- LOG.exception('(PID=%s) Scheduler unexpectedly stopped.', os.getpid())
+ LOG.exception("(PID=%s) Scheduler unexpectedly stopped.", os.getpid())
try:
handler.shutdown()
entrypoint.shutdown()
except:
- LOG.exception('Unable to shutdown scheduler.')
+ LOG.exception("Unable to shutdown scheduler.")
return 1
@@ -127,7 +134,7 @@ def main():
except SystemExit as exit_code:
sys.exit(exit_code)
except:
- LOG.exception('(PID=%s) Scheduler quit due to exception.', os.getpid())
+ LOG.exception("(PID=%s) Scheduler quit due to exception.", os.getpid())
return 1
finally:
_teardown()
