Right now, I catch the exception in the except Exception: clause, and do print(exception). The result provides no information since it always prints
except Exception:
print(exception)
I've use this :
except (socket.timeout, KeyboardInterrupt) as e: logging.debug("Exception : {}".format(str(e.__str__).split(" ")[3])) break
Let me know if it does not work for you !!