mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 12: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
|
# Ensure that only one thread can send data at once
|
||||||
with self._lock:
|
with self._lock:
|
||||||
total_sent = 0
|
view = memoryview(data)
|
||||||
while total_sent < len(data):
|
total_sent, total = 0, len(data)
|
||||||
sent = self._socket.send(data[total_sent:])
|
while total_sent < total:
|
||||||
|
sent = self._socket.send(view[total_sent:])
|
||||||
if sent == 0:
|
if sent == 0:
|
||||||
raise ConnectionResetError(
|
raise ConnectionResetError(
|
||||||
'The server has closed the connection.')
|
'The server has closed the connection.')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user