Skip to content

Commit 53a873f

Browse files
authored
Merge branch 'master' into minor_cleanup_in_ssl_protocol
2 parents 854aa0f + 6a27cbe commit 53a873f

File tree

6 files changed

+167
-116
lines changed

6 files changed

+167
-116
lines changed

tests/test_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,10 @@ async def write_over():
512512
proto.transport.write(b'q' * 16384)
513513
count += 1
514514
else:
515-
proto.transport.write(b'q' * 16384)
516515
proto.transport.set_write_buffer_limits(high=256, low=128)
517-
count += 1
516+
while not proto.transport.get_write_buffer_size():
517+
proto.transport.write(b'q' * 16384)
518+
count += 1
518519
return count
519520

520521
s = self.loop.run_in_executor(None, accept)

tests/test_tcp.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,21 +1226,16 @@ def resume_writing(self):
12261226
t, p = await self.loop.create_connection(Protocol, *addr)
12271227

12281228
t.write(b'q' * 512)
1229-
self.assertEqual(t.get_write_buffer_size(), 512)
1230-
12311229
t.set_write_buffer_limits(low=16385)
1232-
self.assertFalse(paused)
12331230
self.assertEqual(t.get_write_buffer_limits(), (16385, 65540))
12341231

12351232
with self.assertRaisesRegex(ValueError, 'high.*must be >= low'):
12361233
t.set_write_buffer_limits(high=0, low=1)
12371234

12381235
t.set_write_buffer_limits(high=1024, low=128)
1239-
self.assertFalse(paused)
12401236
self.assertEqual(t.get_write_buffer_limits(), (128, 1024))
12411237

12421238
t.set_write_buffer_limits(high=256, low=128)
1243-
self.assertTrue(paused)
12441239
self.assertEqual(t.get_write_buffer_limits(), (128, 256))
12451240

12461241
t.close()

uvloop/handles/stream.pxd

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
cdef enum ProtocolType:
2+
SIMPLE = 0 # User Protocol doesn't support asyncio.BufferedProtocol
3+
BUFFERED = 1 # User Protocol supports asyncio.BufferedProtocol
4+
SSL_PROTOCOL = 2 # Our own SSLProtocol
5+
6+
17
cdef class UVStream(UVBaseTransport):
28
cdef:
39
uv.uv_shutdown_t _shutdown_req
410
bint __shutting_down
511
bint __reading
612
bint __read_error_close
713

8-
bint __buffered
14+
ProtocolType __protocol_type
915
object _protocol_get_buffer
1016
object _protocol_buffer_updated
1117

@@ -16,6 +22,8 @@ cdef class UVStream(UVBaseTransport):
1622
Py_buffer _read_pybuf
1723
bint _read_pybuf_acquired
1824

25+
cpdef write(self, object buf)
26+
1927
# All "inline" methods are final
2028

2129
cdef inline _init(self, Loop loop, object protocol, Server server,
@@ -39,8 +47,8 @@ cdef class UVStream(UVBaseTransport):
3947

4048
# _exec_write() is the method that does the actual send, and _try_write()
4149
# is a fast-path used in _exec_write() to send a single chunk.
42-
cdef inline _exec_write(self)
43-
cdef inline _try_write(self, object data)
50+
cdef inline bint _exec_write(self) except -1
51+
cdef inline Py_ssize_t _try_write(self, object data) except -2
4452

4553
cdef _close(self)
4654

0 commit comments

Comments
 (0)