()
| 432 | # Write BUCKET_KB messages, and return the rate at which they were |
| 433 | # accepted in KB per second. |
| 434 | def write_bucketful(): |
| 435 | nonlocal line_num |
| 436 | start = mock_time() |
| 437 | max_line_num = line_num + BUCKET_KB |
| 438 | while line_num < max_line_num: |
| 439 | stream.write(message.format(line_num)) |
| 440 | line_num += 1 |
| 441 | return BUCKET_KB / (mock_time() - start) |
| 442 | |
| 443 | # The first bucketful should be written with minimal delay. The |
| 444 | # factor of 2 here is not arbitrary: it verifies that the system can |