Test that write() Futures are never orphaned.
(self)
| 887 | |
| 888 | @gen_test |
| 889 | def test_future_write(self): |
| 890 | """ |
| 891 | Test that write() Futures are never orphaned. |
| 892 | """ |
| 893 | # Run concurrent writers that will write enough bytes so as to |
| 894 | # clog the socket buffer and accumulate bytes in our write buffer. |
| 895 | m, n = 5000, 1000 |
| 896 | nproducers = 10 |
| 897 | total_bytes = m * n * nproducers |
| 898 | server, client = yield self.make_iostream_pair(max_buffer_size=total_bytes) |
| 899 | |
| 900 | @gen.coroutine |
| 901 | def produce(): |
| 902 | data = b"x" * m |
| 903 | for i in range(n): |
| 904 | yield server.write(data) |
| 905 | |
| 906 | @gen.coroutine |
| 907 | def consume(): |
| 908 | nread = 0 |
| 909 | while nread < total_bytes: |
| 910 | res = yield client.read_bytes(m) |
| 911 | nread += len(res) |
| 912 | |
| 913 | try: |
| 914 | yield [produce() for i in range(nproducers)] + [consume()] |
| 915 | finally: |
| 916 | server.close() |
| 917 | client.close() |
| 918 | |
| 919 | |
| 920 | class TestIOStreamWebHTTP(AsyncHTTPTestCase, TestIOStreamWebMixin): |
nothing calls this directly
no test coverage detected