测试在linux上可以正常gracefully exit
后期AFK了,工作太忙了
This commit is contained in:
parent
2444545dc1
commit
51e262762a
@ -43,6 +43,9 @@ class IOutput():
|
|||||||
def other_output(self, message_type: str, message_raw: bytes):
|
def other_output(self, message_type: str, message_raw: bytes):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def debug_output(self, message_type: str, message_raw: str):
|
||||||
|
...
|
||||||
|
|
||||||
def error_output(self, message_type: str, message_raw: bytes, exception: Exception):
|
def error_output(self, message_type: str, message_raw: bytes, exception: Exception):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ class OutputManager():
|
|||||||
self.decode_payload(message)
|
self.decode_payload(message)
|
||||||
|
|
||||||
def terminate(self):
|
def terminate(self):
|
||||||
|
if self._should_exit:
|
||||||
self._should_exit.set()
|
self._should_exit.set()
|
||||||
MESSAGE_QUEUE.put(None)
|
MESSAGE_QUEUE.put(None)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ _manager: "Optional[ProxyManager]" = None
|
|||||||
class ProxyManager:
|
class ProxyManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._mitm_instance = None
|
self._mitm_instance = None
|
||||||
|
self._loop: "Optional[asyncio.AbstractEventLoop]" = None
|
||||||
opts = Options(
|
opts = Options(
|
||||||
listen_host=config()['mitm']['host'],
|
listen_host=config()['mitm']['host'],
|
||||||
listen_port=config()['mitm']['port'],
|
listen_port=config()['mitm']['port'],
|
||||||
@ -34,6 +35,9 @@ class ProxyManager:
|
|||||||
self.terminate()
|
self.terminate()
|
||||||
|
|
||||||
def terminate(self):
|
def terminate(self):
|
||||||
|
if self._loop:
|
||||||
|
if self._loop.is_running():
|
||||||
|
self._loop.stop()
|
||||||
if self._mitm_instance:
|
if self._mitm_instance:
|
||||||
self._mitm_instance.shutdown()
|
self._mitm_instance.shutdown()
|
||||||
|
|
||||||
@ -42,6 +46,7 @@ class ProxyManager:
|
|||||||
|
|
||||||
def _start(self):
|
def _start(self):
|
||||||
loop = asyncio.new_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
|
self._loop = loop
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
self._mitm_instance.run()
|
self._mitm_instance.run()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user