mirror of https://github.com/MagicStack/uvloop.git
Add set_protocol and get_protocol to uvloop Transports (issue #42)
This commit is contained in:
parent
b2d34939a1
commit
ad7d2b3821
|
@ -490,6 +490,13 @@ class _TestTCP:
|
|||
t, p = await self.loop.create_connection(
|
||||
lambda: asyncio.Protocol(), *addr)
|
||||
|
||||
if hasattr(t, 'get_protocol'):
|
||||
p2 = asyncio.Protocol()
|
||||
self.assertIs(t.get_protocol(), p)
|
||||
t.set_protocol(p2)
|
||||
self.assertIs(t.get_protocol(), p2)
|
||||
t.set_protocol(p)
|
||||
|
||||
self.assertFalse(t._paused)
|
||||
t.pause_reading()
|
||||
self.assertTrue(t._paused)
|
||||
|
|
|
@ -241,6 +241,12 @@ cdef class UVBaseTransport(UVSocketHandle):
|
|||
def __get__(self):
|
||||
return bool(not self._is_reading())
|
||||
|
||||
def get_protocol(self):
|
||||
return self._protocol
|
||||
|
||||
def set_protocol(self, protocol):
|
||||
self._set_protocol(protocol)
|
||||
|
||||
def _force_close(self, exc):
|
||||
# Used by SSLProto. Might be removed in the future.
|
||||
if self._conn_lost or self._closed:
|
||||
|
|
|
@ -570,6 +570,12 @@ cdef class UVProcessTransport(UVProcess):
|
|||
|
||||
return handle
|
||||
|
||||
def get_protocol(self):
|
||||
return self._protocol
|
||||
|
||||
def set_protocol(self, protocol):
|
||||
self._protocol = protocol
|
||||
|
||||
def get_pid(self):
|
||||
return self._pid
|
||||
|
||||
|
|
Loading…
Reference in New Issue