GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#5)
by
unknown
09:42 queued 01:59
created

st2actions.cmd._run_worker()   A

Complexity

Conditions 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
dl 0
loc 14
rs 9.4285
1
import eventlet
2
import os
3
import sys
4
5
from st2common import log as logging
6
from st2common.service_setup import setup as common_setup
7
from st2common.service_setup import teardown as common_teardown
8
from st2actions.notifier import config
9
from st2actions.notifier import notifier
10
from st2actions.notifier import scheduler
11
12
13
LOG = logging.getLogger(__name__)
14
15
16
eventlet.monkey_patch(
17
    os=True,
18
    select=True,
19
    socket=True,
20
    thread=False if '--use-debugger' in sys.argv else True,
21
    time=True)
22
23
24
def _setup():
25
    common_setup(service='notifier', config=config, setup_db=True, register_mq_exchanges=True,
26
                 register_signal_handlers=True)
27
28
29
def _run_worker():
30
    LOG.info('(PID=%s) Actions notifier started.', os.getpid())
31
    actions_notifier = notifier.get_notifier()
32
    actions_rescheduler = scheduler.get_rescheduler()
33
    try:
34
        eventlet.spawn(actions_rescheduler.start)
35
        actions_notifier.start(wait=True)
36
    except (KeyboardInterrupt, SystemExit):
37
        LOG.info('(PID=%s) Actions notifier stopped.', os.getpid())
38
        actions_rescheduler.shutdown()
39
        actions_notifier.shutdown()
40
    except:
41
        return 1
42
    return 0
43
44
45
def _teardown():
46
    common_teardown()
47
48
49
def main():
50
    try:
51
        _setup()
52
        return _run_worker()
53
    except SystemExit as exit_code:
54
        sys.exit(exit_code)
55
    except:
56
        LOG.exception('(PID=%s) Results tracker quit due to exception.', os.getpid())
57
        return 1
58
    finally:
59
        _teardown()
60