Skip to content

Commit

Permalink
Speed up shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Aug 30, 2017
1 parent 2dca9d6 commit f376a25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 4 additions & 6 deletions tuxeatpi_common/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""TuxEatPi Base Main module"""

import os
import sys

import click
from setproctitle import setproctitle # pylint: disable=E0611
Expand Down Expand Up @@ -34,13 +34,11 @@ def main_cli(workdir, intent_folder, dialog_folder, **kwargs):
# Get workdir
if workdir is None:
workdir = os.getcwd()
prog_name = DAEMON_CLASS.__name__.lower()
if not prog_name.startswith("tep-"):
proc_title = "tep-" + prog_name
else:
proc_title = prog_name
# Set proc_title
proc_title = os.path.basename(sys.argv[0])
setproctitle(proc_title)
# Standard preparation
prog_name = DAEMON_CLASS.__name__.lower()
tep_daemon = DAEMON_CLASS(prog_name, workdir, intent_folder, dialog_folder, **kwargs)
# Run the deamon
tep_daemon.start()
Expand Down
10 changes: 8 additions & 2 deletions tuxeatpi_common/subtasker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ def __init__(self, component):
@asyncio.coroutine
def _send_alive(self):
"""Send alive request every 15 seconds"""
# TODO improve me
wait_count = 15
while True:
self.component.registry.ping()
yield from asyncio.sleep(15)
if wait_count < 15:
wait_count += 1
yield from asyncio.sleep(1)
else:
self.component.registry.ping()
wait_count = 0

# @asyncio.coroutine
# def _wait_for_reload(self):
Expand Down

0 comments on commit f376a25

Please sign in to comment.