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,13 +293,17 @@ class Server:
|
||||||
) -> None:
|
) -> None:
|
||||||
events = self.events.get(event, [])
|
events = self.events.get(event, [])
|
||||||
coroutines: List[Coroutine] = []
|
coroutines: List[Coroutine] = []
|
||||||
for func in events:
|
try:
|
||||||
ret = func(*args)
|
for func in events:
|
||||||
if ret is not None:
|
ret = func(*args)
|
||||||
coroutines.append(ret)
|
if ret is not None:
|
||||||
if coroutines:
|
coroutines.append(ret)
|
||||||
await asyncio.gather(*coroutines)
|
if coroutines:
|
||||||
fut.set_result(None)
|
await asyncio.gather(*coroutines)
|
||||||
|
except ServerError as e:
|
||||||
|
logging.exception(f"Error Processing Event: {fut}")
|
||||||
|
if not fut.done():
|
||||||
|
fut.set_result(None)
|
||||||
|
|
||||||
def register_remote_method(self,
|
def register_remote_method(self,
|
||||||
method_name: str,
|
method_name: str,
|
||||||
|
|
Loading…
Reference in New Issue