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:
|
||||
events = self.events.get(event, [])
|
||||
coroutines: List[Coroutine] = []
|
||||
for func in events:
|
||||
ret = func(*args)
|
||||
if ret is not None:
|
||||
coroutines.append(ret)
|
||||
if coroutines:
|
||||
await asyncio.gather(*coroutines)
|
||||
fut.set_result(None)
|
||||
try:
|
||||
for func in events:
|
||||
ret = func(*args)
|
||||
if ret is not None:
|
||||
coroutines.append(ret)
|
||||
if coroutines:
|
||||
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,
|
||||
method_name: str,
|
||||
|
|
Loading…
Reference in New Issue