replace hasattr with getattr for cleaner code

This commit is contained in:
Huy Pham 2020-02-24 11:24:59 -08:00
parent 04d7bb6265
commit 7a50f6ac25

View file

@ -22,8 +22,8 @@ class BackgroundTask:
result = self.task(*self.args)
logging.info("task completed")
# if start session fails, a response with Result: False and a list of exceptions is returned
if hasattr(result, "result") and not result.result:
if hasattr(result, "exceptions") and len(result.exceptions) > 0:
if not getattr(result, "result", True):
if len(getattr(result, "exceptions", [])) > 0:
self.master.after(
0,
show_grpc_response_exceptions,