Part of bzrlib.tests.stub_sftp View In Hierarchy
This changes recv, send, and sendall to add a fixed latency to each python call if a new roundtrip is detected. That is, when a recv is called and the flag new_roundtrip is set, latency is charged. Every send and send_all sets this flag.
In addition every send, sendall and recv sleeps a bit per character send to simulate bandwidth.
Not all methods are implemented, this is deliberate as this class is not a replacement for the builtin sockets layer. fileno is not implemented to prevent the proxy being bypassed.
:param bandwith: simulated bandwith (MegaBit) :param really_sleep: If set to false, the SocketDelay will just increase a counter, instead of calling time.sleep. This is useful for unittesting the SocketDelay.