Create a basic async loop.

This commit is contained in:
Eli Ribble 2023-05-12 14:13:27 -07:00
parent 409e6152ae
commit bc79e842e7
1 changed files with 24 additions and 1 deletions

View File

@ -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")