You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
526 B
Python
19 lines
526 B
Python
2 weeks ago
|
import asyncio
|
||
|
import sys
|
||
|
import traceback
|
||
|
from typing import Coroutine
|
||
|
|
||
|
|
||
|
async def run_listeners(listeners: list, *args, **kwargs) -> Coroutine[None, None, None]:
|
||
|
for listener in listeners:
|
||
|
try:
|
||
|
res = listener(*args, **kwargs)
|
||
|
if asyncio.iscoroutine(res):
|
||
|
await res
|
||
|
except Exception as ex:
|
||
|
print(
|
||
|
"Error while processing callback: %s" % ex,
|
||
|
file=sys.stderr,
|
||
|
)
|
||
|
traceback.print_exc()
|
||
|
return None
|