Skip to content

Commit

Permalink
Optimize reading huge packet (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deneby67 authored and methane committed Feb 5, 2019
1 parent d063f68 commit 3539f87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def _read_packet(self, packet_type=MysqlPacket):
:raise OperationalError: If the connection to the MySQL server is lost.
:raise InternalError: If the packet sequence number is wrong.
"""
buff = b''
buff = bytearray()
while True:
packet_header = self._read_bytes(4)
#if DEBUG: dump_packet(packet_header)
Expand Down Expand Up @@ -666,7 +666,7 @@ def _read_packet(self, packet_type=MysqlPacket):
if bytes_to_read < MAX_PACKET_LEN:
break

packet = packet_type(buff, self.encoding)
packet = packet_type(bytes(buff), self.encoding)
packet.check_error()
return packet

Expand Down

0 comments on commit 3539f87

Please sign in to comment.