server: handle event exceptions
Don't allow exceptions to propagate beyond a call to _process_event(). Make sure the future is not marked as done prior to setting the result. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
4bed314b0a
commit
1eaead1073
|
@ -293,12 +293,16 @@ class Server:
|
||||||
) -> None:
|
) -> None:
|
||||||
events = self.events.get(event, [])
|
events = self.events.get(event, [])
|
||||||
coroutines: List[Coroutine] = []
|
coroutines: List[Coroutine] = []
|
||||||
|
try:
|
||||||
for func in events:
|
for func in events:
|
||||||
ret = func(*args)
|
ret = func(*args)
|
||||||
if ret is not None:
|
if ret is not None:
|
||||||
coroutines.append(ret)
|
coroutines.append(ret)
|
||||||
if coroutines:
|
if coroutines:
|
||||||
await asyncio.gather(*coroutines)
|
await asyncio.gather(*coroutines)
|
||||||
|
except ServerError as e:
|
||||||
|
logging.exception(f"Error Processing Event: {fut}")
|
||||||
|
if not fut.done():
|
||||||
fut.set_result(None)
|
fut.set_result(None)
|
||||||
|
|
||||||
def register_remote_method(self,
|
def register_remote_method(self,
|
||||||
|
|
Loading…
Reference in New Issue