Merge pull request #43 from amhirsch/debug-stream

Add debugging option
This commit is contained in:
Junzi Sun 2019-06-06 11:32:33 +02:00 committed by GitHub
commit d230bdc4a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import sys
import socket import socket
import time import time
from threading import Thread from threading import Thread
import traceback
if (sys.version_info > (3, 0)): if (sys.version_info > (3, 0)):
PY_VERSION = 3 PY_VERSION = 3
@ -269,7 +270,16 @@ class BaseClient(Thread):
time.sleep(0.001) time.sleep(0.001)
except Exception as e: 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: try:
sock = self.connect() sock = self.connect()