Open
Description
when observer raises an exception and there is no error_event
, logging fails
def __call__(self, caller, *args, **kwargs):
"""Loop over all active callbacks and call them"""
for slot in self.slots.copy():
ref = slot.weakref
func = slot.func
try:
if ref:
obj = ref()
else:
obj = slot.obj
result = None
if obj is None:
if func:
result = func(*args, **kwargs)
else:
if func:
result = func(obj, *args, **kwargs)
else:
result = obj(*args, **kwargs)
# even though asyncio.iscoroutine() would also work here,
# this manual hasattr() check performs better.
if result and hasattr(result, "__await__"):
asyncio.ensure_future(result, loop=get_event_loop())
except Exception as error:
# It's not really clear in the documentation or usage that exceptions
# get returned via an 'error_event' callback. We should make sure
# people know this clearly so event handler callback errors are noticed.
if len(caller.error_event):
caller.error_event.emit(caller, error)
else:
> Event.logger.exception(
f"Value {args} caused exception for event {caller}"
)
E AttributeError: type object 'Event' has no attribute 'logger'
eventkit/event.py:112: AttributeError
Metadata
Metadata
Assignees
Labels
No labels