diff --git a/libmproxy/console.py b/libmproxy/console.py index ed6c78afc..399640c22 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -1023,6 +1023,10 @@ class ConsoleMaster(flow.FlowMaster): self.onekey = False self.view_connlist() + self.masterq = Queue.Queue() + slave = controller.Slave(self.masterq, self.server) + slave.start() + self.ui.run_wrapper(self.loop) # If True, quit just pops out to connection list view. print >> sys.stderr, "Shutting down..." @@ -1294,16 +1298,12 @@ class ConsoleMaster(flow.FlowMaster): return size def loop(self): - q = Queue.Queue() - self.masterq = q - slave = controller.Slave(q, self.server) - slave.start() try: while not controller.exit: startloop = time.time() self.statusbar.redraw() size = self.drawscreen() - self.tick(q) + self.tick(self.masterq) self.ui.set_input_timeouts(max_wait=0.1) keys = self.ui.get_input() for k in keys: diff --git a/libmproxy/controller.py b/libmproxy/controller.py index 52b6ac6b5..f0e65e7f1 100644 --- a/libmproxy/controller.py +++ b/libmproxy/controller.py @@ -59,7 +59,7 @@ class Slave(threading.Thread): class Master: def __init__(self, server): self.server = server - self.masterq = None + self.masterq = Queue.Queue() def tick(self, q): try: @@ -75,12 +75,10 @@ class Master: pass def run(self): - q = Queue.Queue() - self.masterq = q - slave = Slave(q, self.server) + slave = Slave(self.masterq, self.server) slave.start() while not exit: - self.tick(q) + self.tick(self.masterq) self.shutdown() def handle(self, msg):