Commit 4d045403 authored by Luke Macken's avatar Luke Macken

reverse: Ensure we don't permanently hijack stdout/err or leave sockets open

parent fa2cffe2
...@@ -109,6 +109,7 @@ class ReversePythonConnection(ReverseConnection): ...@@ -109,6 +109,7 @@ class ReversePythonConnection(ReverseConnection):
output = buffer.getvalue() output = buffer.getvalue()
except: except:
output = traceback.format_exc() output = traceback.format_exc()
finally:
sys.stdout = sys.__stdout__ sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__ sys.stderr = sys.__stderr__
buffer.close() buffer.close()
...@@ -186,6 +187,6 @@ class ReversePythonShell(threading.Thread, pyrasite.PyrasiteIPC): ...@@ -186,6 +187,6 @@ class ReversePythonShell(threading.Thread, pyrasite.PyrasiteIPC):
pass pass
except: except:
traceback.print_exc(file=sys.__stderr__) traceback.print_exc(file=sys.__stderr__)
finally:
sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__ sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
self.close() self.close()
...@@ -73,7 +73,7 @@ def shell(): ...@@ -73,7 +73,7 @@ def shell():
except: except:
print('') print('')
raise raise
finally:
ipc.close() ipc.close()
......
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