diff options
Diffstat (limited to 'libmproxy/controller.py')
-rw-r--r-- | libmproxy/controller.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libmproxy/controller.py b/libmproxy/controller.py index 4a72cf80..39e7695f 100644 --- a/libmproxy/controller.py +++ b/libmproxy/controller.py @@ -77,7 +77,7 @@ class Slave(threading.Thread): self.server.serve_forever() -class Master: +class Master(object): """ Masters get and respond to messages from slaves. """ @@ -89,7 +89,7 @@ class Master: self.masterq = Queue.Queue() self.should_exit = threading.Event() - def tick(self, q): + def tick(self, q, timeout): changed = False try: # This endless loop runs until the 'Queue.Empty' @@ -97,8 +97,7 @@ class Master: # 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) + msg = q.get(timeout=timeout) self.handle(*msg) changed = True except Queue.Empty: @@ -109,7 +108,7 @@ class Master: self.should_exit.clear() self.server.start_slave(Slave, Channel(self.masterq, self.should_exit)) while not self.should_exit.is_set(): - self.tick(self.masterq) + self.tick(self.masterq, 0.01) self.shutdown() def handle(self, mtype, obj): |