Simulating service latency during the development phase of a service is good practice, as it forces developers to write code that acts gracefully and resiliently in the event of unexpected latency during network io.

To add latency to services, simply add the FQDN, delay in milliseconds, and optional HTTP method in an array of tuples for the delays parameter.


from hoverpy import capture
import requests

delays = [("", 3000, "GET"), ("", 1000)]

@capture("delays.db", recordMode="once", delays=delays)
def simulate_network_latency():

$ python examples/latency/

The latency is added when querying these services. If the HTTP method is omitted in the tupes, then the delay applies to all methods.