diff options
author | Thomas Roth <code@leveldown.de> | 2010-02-25 17:49:21 +0100 |
---|---|---|
committer | Thomas Roth <code@leveldown.de> | 2010-02-25 17:49:21 +0100 |
commit | fc6f170731e2c9a21ffcaac5f0bb5f8156ccd1c9 (patch) | |
tree | 23bb3974424a61b9180f722451ca1208aee8fd8c /libmproxy/controller.py | |
parent | 1909744631033cba92f19433061e6a7c802d7766 (diff) | |
download | mitmproxy-fc6f170731e2c9a21ffcaac5f0bb5f8156ccd1c9.tar.gz mitmproxy-fc6f170731e2c9a21ffcaac5f0bb5f8156ccd1c9.tar.bz2 mitmproxy-fc6f170731e2c9a21ffcaac5f0bb5f8156ccd1c9.zip |
Huge speed improvements if more than one request is in the queue. Speeds up every request by 0.1 seconds.
Diffstat (limited to 'libmproxy/controller.py')
-rw-r--r-- | libmproxy/controller.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libmproxy/controller.py b/libmproxy/controller.py index 4955aae3..f20d17b4 100644 --- a/libmproxy/controller.py +++ b/libmproxy/controller.py @@ -52,9 +52,14 @@ class Master: def tick(self, q): try: - # Small timeout to prevent pegging the CPU - msg = q.get(timeout=0.01) - self.handle(msg) + # This endless loop is running until the 'Queue.Empty' + # exception is thrown. If more than one request is in + # the queue, this speeds up every request by 0.1 seconds, + # because get_input(..) function is not blocking. + while True: + # Small timeout to prevent pegging the CPU + msg = q.get(timeout=0.01) + self.handle(msg) except Queue.Empty: pass |