Commit 9acbd581 authored by Luke Macken's avatar Luke Macken

Handle exceptions in a 2.4->3.x friendly way.

parent 42dbec38
......@@ -21,6 +21,7 @@
import sys
import socket
import traceback
import threading
if sys.version_info[0] == 3:
......@@ -82,8 +83,8 @@ class ReverseConnection(threading.Thread, PyrasiteIPC):
else:
running = self.on_command(cmd)
except Exception as e:
print(str(e))
except:
traceback.print_exc()
running = False
if not running:
self.close()
......@@ -102,11 +103,11 @@ class ReversePythonConnection(ReverseConnection):
try:
exec(cmd)
output = buffer.getvalue()
except Exception as e:
output = str(e)
finally:
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
buffer.close()
except:
exc_type, exc_value, exc_tb = sys.exc_info()
output = exc_value.message
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
buffer.close()
self.send(output)
return True
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment