Skip to content

Commit 2c5961b

Browse files
Merge pull request #41 from dls-controls/add_async_logging
Provide logging for exceptions raised in callbacks
2 parents 4219994 + 82cd403 commit 2c5961b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

softioc/asyncio_dispatcher.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import inspect
3+
import logging
34
import threading
45
import atexit
56

@@ -28,7 +29,10 @@ def aioJoin(worker=worker, loop=self.loop):
2829

2930
def __call__(self, func, *args):
3031
async def async_wrapper():
31-
ret = func(*args)
32-
if inspect.isawaitable(ret):
33-
await ret
32+
try:
33+
ret = func(*args)
34+
if inspect.isawaitable(ret):
35+
await ret
36+
except Exception:
37+
logging.exception("Exception when awaiting callback")
3438
asyncio.run_coroutine_threadsafe(async_wrapper(), self.loop)

0 commit comments

Comments
 (0)