MCPcopy
hub / github.com/tornadoweb/tornado / test_future_write

Method test_future_write

tornado/test/iostream_test.py:889–917  ·  view source on GitHub ↗

Test that write() Futures are never orphaned.

(self)

Source from the content-addressed store, hash-verified

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
920class TestIOStreamWebHTTP(AsyncHTTPTestCase, TestIOStreamWebMixin):

Callers

nothing calls this directly

Calls 2

make_iostream_pairMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected