cleanup code
This commit is contained in:
@@ -18,7 +18,9 @@ import argparse
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
import os
|
||||||
import pyinotify
|
import pyinotify
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -235,7 +237,8 @@ def add_mask(new_mask, current_mask=False):
|
|||||||
|
|
||||||
|
|
||||||
async def shutdown(timeout=30):
|
async def shutdown(timeout=30):
|
||||||
pending = [ t for t in asyncio.all_tasks() if t is not asyncio.current_task() ]
|
pending = [t for t in asyncio.all_tasks()
|
||||||
|
if t is not asyncio.current_task()]
|
||||||
if len(pending) > 0:
|
if len(pending) > 0:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"graceful shutdown, waiting {timeout}s "
|
f"graceful shutdown, waiting {timeout}s "
|
||||||
@@ -272,6 +275,8 @@ def main():
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
LOGLEVEL = logging.INFO
|
||||||
|
WATCHES = []
|
||||||
with open(args.config, "r") as c:
|
with open(args.config, "r") as c:
|
||||||
exec(c.read(), globals())
|
exec(c.read(), globals())
|
||||||
|
|
||||||
@@ -282,10 +287,8 @@ def main():
|
|||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
loglevel = logging.DEBUG
|
loglevel = logging.DEBUG
|
||||||
elif "LOGLEVEL" in globals():
|
|
||||||
loglevel = LOGLEVEL
|
|
||||||
else:
|
else:
|
||||||
loglevel = logging.INFO
|
loglevel = LOGLEVEL
|
||||||
|
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
root_logger.setLevel(loglevel)
|
root_logger.setLevel(loglevel)
|
||||||
|
|||||||
Reference in New Issue
Block a user