'Run the MitmLoop.
This calls select on all active sockets and dispatches the resulting sockets to the
connection and blame servers.
Keyword arguments:
only_once -- run the select loop only once instead of forever (default False)
timeout -- the timeout for select in seconds (default 5)'

def run(self, only_once=False, timeout=5):

    servers = self._servers
    while True:
        fds = {server: set([sock for fds in server.select_fds for sock in fds]) for server in servers}
        (r, w, x) = [set().union(*l) for l in zip(*[server.select_fds for server in servers])]
        (r, w, x) = select.select(r, w, x, timeout)
        for server in servers:
            filter_func = (lambda fd: (fd in fds[server]))
            server.on_select(filter(filter_func, r), filter(filter_func, w), filter(filter_func, x))
        if only_once:
            return
