diff --git a/pyModeS/extra/tcpclient.py b/pyModeS/extra/tcpclient.py index 22539b6..e8d15d0 100644 --- a/pyModeS/extra/tcpclient.py +++ b/pyModeS/extra/tcpclient.py @@ -7,6 +7,7 @@ import sys import socket import time from threading import Thread +import traceback if (sys.version_info > (3, 0)): PY_VERSION = 3 @@ -269,7 +270,16 @@ class BaseClient(Thread): time.sleep(0.001) except Exception as e: - print("Unexpected Error:", e) + + # Provides the user an option to supply the environment + # variable PYMODES_DEBUG to halt the execution + # for debugging purposes + debug_intent = os.environ.get('PYMODES_DEBUG', None) + if debug_intent.lower() == 'true': + traceback.print_exc() + sys.exit() + else: + print("Unexpected Error:", e) try: sock = self.connect()