Skip to content

Commit

Permalink
log error in async_test
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlim94 committed Sep 23, 2023
1 parent 498cb7a commit a12d681
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/util.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import asyncio
import logging

format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
logger = logging.getLogger()


def async_test(coro):
def wrapper(*args, **kwargs):
loop = asyncio.new_event_loop()
try:
return loop.run_until_complete(coro(*args, **kwargs))
except Exception as err:
logger.error(err)
finally:
loop.close()

Expand Down

0 comments on commit a12d681

Please sign in to comment.