Revert "handle signals for better app shutdown"
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This reverts commit 573765958f
.
This commit is contained in:
parent
573765958f
commit
5aae306119
|
@ -2,6 +2,6 @@
|
||||||
Pylokid. From Mail to Lodur - all automated.
|
Pylokid. From Mail to Lodur - all automated.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = "3.0.3"
|
__version__ = "3.0.2"
|
||||||
__git_version__ = "0"
|
__git_version__ = "0"
|
||||||
__url__ = "https://github.com/tobru/pylokid"
|
__url__ = "https://github.com/tobru/pylokid"
|
||||||
|
|
|
@ -4,4 +4,7 @@ Helper module to run not-installed version (via ``python3 -m pylokid``)
|
||||||
from pylokid.main import main
|
from pylokid.main import main
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
try:
|
||||||
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("Byebye")
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import signal
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from importlib.metadata import version
|
from importlib.metadata import version
|
||||||
|
@ -38,20 +37,6 @@ PUSHOVER_API_TOKEN = os.getenv("PUSHOVER_API_TOKEN")
|
||||||
PUSHOVER_USER_KEY = os.getenv("PUSHOVER_USER_KEY")
|
PUSHOVER_USER_KEY = os.getenv("PUSHOVER_USER_KEY")
|
||||||
|
|
||||||
|
|
||||||
class GracefulKiller:
|
|
||||||
kill_now = False
|
|
||||||
signals = {signal.SIGINT: "SIGINT", signal.SIGTERM: "SIGTERM"}
|
|
||||||
|
|
||||||
def __init__(self, logger):
|
|
||||||
signal.signal(signal.SIGINT, self.exit_gracefully)
|
|
||||||
signal.signal(signal.SIGTERM, self.exit_gracefully)
|
|
||||||
self.logger = logger
|
|
||||||
|
|
||||||
def exit_gracefully(self, signum, frame):
|
|
||||||
self.logger.info("Received signal %s", self.signals[signum])
|
|
||||||
self.kill_now = True
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main """
|
""" main """
|
||||||
|
|
||||||
|
@ -63,8 +48,6 @@ def main():
|
||||||
logger = logging.getLogger("pylokid")
|
logger = logging.getLogger("pylokid")
|
||||||
logger.info("Starting pylokid version %s", version("pylokid"))
|
logger.info("Starting pylokid version %s", version("pylokid"))
|
||||||
|
|
||||||
killer = GracefulKiller(logger)
|
|
||||||
|
|
||||||
# Initialize IMAP Session
|
# Initialize IMAP Session
|
||||||
imap_client = EmailHandling(
|
imap_client = EmailHandling(
|
||||||
IMAP_SERVER,
|
IMAP_SERVER,
|
||||||
|
@ -261,11 +244,6 @@ def main():
|
||||||
|
|
||||||
# send heartbeat
|
# send heartbeat
|
||||||
requests.get(HEARTBEAT_URL)
|
requests.get(HEARTBEAT_URL)
|
||||||
|
# repeat every
|
||||||
while not killer.kill_now:
|
logger.info("Waiting %s seconds until next check", IMAP_CHECK_INTERVAL)
|
||||||
# repeat every
|
time.sleep(int(IMAP_CHECK_INTERVAL))
|
||||||
logger.info("Waiting %s seconds until next check", IMAP_CHECK_INTERVAL)
|
|
||||||
time.sleep(int(IMAP_CHECK_INTERVAL))
|
|
||||||
|
|
||||||
logger.info("Pylokid waves bye bye")
|
|
||||||
exit()
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pylokid"
|
name = "pylokid"
|
||||||
version = "3.0.3"
|
version = "3.0.2"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Tobias Brunner <tobias@tobru.ch>"]
|
authors = ["Tobias Brunner <tobias@tobru.ch>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
Loading…
Reference in New Issue