Skip to content

Commit

Permalink
throttle don't sleep with 0 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
hackaugusto authored and LefterisJP committed Sep 4, 2017
1 parent ef6b10e commit 1d99856
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion raiden/network/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ def send(self, sender, host_port, bytes_):
host_port (Tuple[(str, int)]): Tuple with the host name and port number.
bytes_ (bytes): The bytes that are going to be sent through the wire.
"""
gevent.sleep(self.throttle_policy.consume(1))
sleep_timeout = self.throttle_policy.consume(1)

# Don't sleep if timeout is zero, otherwise a context-switch is done
# and the message is delayed, increasing it's latency
if sleep_timeout:
gevent.sleep(sleep_timeout)

self.server.sendto(bytes_, host_port)

# enable debugging using the DummyNetwork callbacks
Expand Down

0 comments on commit 1d99856

Please sign in to comment.