Create a basic async loop.
This commit is contained in:
parent
409e6152ae
commit
bc79e842e7
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in New Issue