mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Use memoryview() on TcpClient.write() instead slicing the data
This commit is contained in:
parent
c6645a555d
commit
ba5bfa105f
|
@ -50,9 +50,10 @@ class TcpClient:
|
|||
|
||||
# Ensure that only one thread can send data at once
|
||||
with self._lock:
|
||||
total_sent = 0
|
||||
while total_sent < len(data):
|
||||
sent = self._socket.send(data[total_sent:])
|
||||
view = memoryview(data)
|
||||
total_sent, total = 0, len(data)
|
||||
while total_sent < total:
|
||||
sent = self._socket.send(view[total_sent:])
|
||||
if sent == 0:
|
||||
raise ConnectionResetError(
|
||||
'The server has closed the connection.')
|
||||
|
|
Loading…
Reference in New Issue
Block a user