From bc79e842e73cd6b719f404a6d14ffae3c66b58f2 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 12 May 2023 14:13:27 -0700 Subject: [PATCH] Create a basic async loop. --- pnpdevice/main.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pnpdevice/main.py b/pnpdevice/main.py index bc1f03a..bdab544 100644 --- a/pnpdevice/main.py +++ b/pnpdevice/main.py @@ -1,2 +1,25 @@ +import argparse +import asyncio +import logging + + +LOGGER = logging.getLogger(__name__) + +async def run(): + while True: + await asyncio.sleep(1) + LOGGER.info("Tick.") + def main(): - print("Hello, world") + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose logging") + args = parser.parse_args() + + logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) + + loop = asyncio.get_event_loop() + try: + loop.run_until_complete(run()) + except KeyboardInterrupt: + LOGGER.info("Shutting down") +