self._bytesSent = 0
self._timeCreated = time.time()
self._socket = socket.socket()

def send(self, bytes):
    now = time.time()
connectionDuration = now - self._timeCreated
self._bytesSent += len(bytes)
requiredDuration = self._bytesSent / self._bandwidth
time.sleep(max(requiredDuration - connectionDuration, self._latency))
return self._socket.send(bytes)
Простой способ имитировать медленную сеть в python