MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / send_data

Method send_data

pager_lib/pymysql/connections.py:1411–1435  ·  view source on GitHub ↗

Send data packets from the local file to the server

(self)

Source from the content-addressed store, hash-verified

1409 self.connection = connection
1410
1411 def send_data(self):
1412 """Send data packets from the local file to the server"""
1413 if not self.connection._sock:
1414 raise err.InterfaceError(0, "")
1415 conn: Connection = self.connection
1416
1417 try:
1418 with open(self.filename, "rb") as open_file:
1419 packet_size = min(
1420 conn.max_allowed_packet, 16 * 1024
1421 ) # 16KB is efficient enough
1422 while True:
1423 chunk = open_file.read(packet_size)
1424 if not chunk:
1425 break
1426 conn.write_packet(chunk)
1427 except OSError:
1428 raise err.OperationalError(
1429 ER.FILE_NOT_FOUND,
1430 f"Can't find file '{self.filename}'",
1431 )
1432 finally:
1433 if not conn._closed:
1434 # send the empty packet to signify we are done sending data
1435 conn.write_packet(b"")

Callers 1

Calls 2

write_packetMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected