Skip to content

Commit 946e2bd

Browse files
committed
Move all mentions of transport from CoreProtocol to BaseProtocol
Transport is an asyncio concern and should logically be in the BaseProtocol.
1 parent 263de3f commit 946e2bd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

asyncpg/protocol/coreproto.pyx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ cdef class CoreProtocol:
1717
self.password = con_params.password
1818
self.auth_msg = None
1919
self.con_params = con_params
20-
self.transport = None
2120
self.con_status = CONNECTION_BAD
2221
self.state = PROTOCOL_IDLE
2322
self.xact_status = PQTRANS_IDLE
@@ -32,9 +31,6 @@ cdef class CoreProtocol:
3231

3332
self._reset_result()
3433

35-
cdef _write(self, buf):
36-
self.transport.write(memoryview(buf))
37-
3834
cdef _read_server_messages(self):
3935
cdef:
4036
char mtype
@@ -147,7 +143,6 @@ cdef class CoreProtocol:
147143
if self.result_type != RESULT_OK:
148144
self.con_status = CONNECTION_BAD
149145
self._push_result()
150-
self.transport.close()
151146

152147
elif self.auth_msg is not None:
153148
# Server wants us to send auth data, so do that.
@@ -910,6 +905,9 @@ cdef class CoreProtocol:
910905
buf.end_message()
911906
self._write(buf)
912907

908+
cdef _write(self, buf):
909+
raise NotImplementedError
910+
913911
cdef _decode_row(self, const char* buf, ssize_t buf_len):
914912
pass
915913

asyncpg/protocol/protocol.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ cdef class BaseProtocol(CoreProtocol):
9898
CoreProtocol.__init__(self, con_params)
9999

100100
self.loop = loop
101+
self.transport = None
101102
self.waiter = connected_fut
102103
self.cancel_waiter = None
103104
self.cancel_sent_waiter = None
@@ -883,6 +884,9 @@ cdef class BaseProtocol(CoreProtocol):
883884
self.closing = True
884885
self._handle_waiter_on_connection_lost(exc)
885886

887+
cdef _write(self, buf):
888+
self.transport.write(memoryview(buf))
889+
886890
# asyncio callbacks:
887891

888892
def data_received(self, data):

0 commit comments

Comments
 (0)