MCPcopy Create free account
hub / github.com/requests-cache/requests-cache / get_randomized_response

Function get_randomized_response

examples/benchmark.py:75–81  ·  view source on GitHub ↗

Get a response with randomized content

(i=0, max_size=MAX_RESPONSE_SIZE)

Source from the content-addressed store, hash-verified

73
74
75def get_randomized_response(i=0, max_size=MAX_RESPONSE_SIZE):
76 """Get a response with randomized content"""
77 new_response = CachedResponse.from_response(BASE_RESPONSE)
78 n_bytes = int(random() * max_size)
79 new_response._content = urandom(n_bytes)
80 new_response.request.url += f'/response_{i}'
81 return new_response
82
83
84if __name__ == '__main__':

Callers 1

test_write_speedFunction · 0.70

Calls 1

from_responseMethod · 0.45

Tested by 1

test_write_speedFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…