mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Don't redraw the screen more often than necessary.
This commit is contained in:
parent
b04d074341
commit
2ae7808ca9
@ -1306,14 +1306,18 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
return size
|
||||
|
||||
def loop(self):
|
||||
changed = True
|
||||
try:
|
||||
while not controller.exit:
|
||||
startloop = time.time()
|
||||
if changed:
|
||||
self.statusbar.redraw()
|
||||
size = self.drawscreen()
|
||||
self.tick(self.masterq)
|
||||
changed = self.tick(self.masterq)
|
||||
self.ui.set_input_timeouts(max_wait=0.1)
|
||||
keys = self.ui.get_input()
|
||||
if keys:
|
||||
changed = True
|
||||
for k in keys:
|
||||
if self.prompting:
|
||||
if k == "esc":
|
||||
|
@ -65,6 +65,7 @@ class Master:
|
||||
self.masterq = Queue.Queue()
|
||||
|
||||
def tick(self, q):
|
||||
changed = False
|
||||
try:
|
||||
# This endless loop runs until the 'Queue.Empty'
|
||||
# exception is thrown. If more than one request is in
|
||||
@ -74,8 +75,10 @@ class Master:
|
||||
# Small timeout to prevent pegging the CPU
|
||||
msg = q.get(timeout=0.01)
|
||||
self.handle(msg)
|
||||
changed = True
|
||||
except Queue.Empty:
|
||||
pass
|
||||
return changed
|
||||
|
||||
def run(self):
|
||||
if self.server:
|
||||
|
@ -540,7 +540,7 @@ class FlowMaster(controller.Master):
|
||||
if self.server_playback.exit and self.server_playback.count() == 0:
|
||||
self.shutdown()
|
||||
|
||||
controller.Master.tick(self, q)
|
||||
return controller.Master.tick(self, q)
|
||||
|
||||
def load_flows(self, fr):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user