mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 18:46:40 +00:00
Remove TcpClient.write/read shared locks
Since they were shared between write and read, and now the read is done constantly on a separate thread, the read lock would cause the write method to be locked and not functional at all
This commit is contained in:
parent
43b79c3d36
commit
cc280a129d
@ -65,8 +65,9 @@ class TcpClient:
|
||||
def write(self, data):
|
||||
"""Writes (sends) the specified bytes to the connected peer"""
|
||||
|
||||
# Ensure that only one thread can send data at once
|
||||
with self._lock:
|
||||
# TODO Check whether the code using this has multiple threads calling
|
||||
# .write() on the very same socket. If so, have two locks, one for
|
||||
# .write() and another for .read().
|
||||
try:
|
||||
view = memoryview(data)
|
||||
total_sent, total = 0, len(data)
|
||||
@ -95,8 +96,6 @@ class TcpClient:
|
||||
operation. Set to None for no timeout
|
||||
"""
|
||||
|
||||
# Ensure that only one thread can receive data at once
|
||||
with self._lock:
|
||||
# Ensure it is not cancelled at first, so we can enter the loop
|
||||
self.cancelled.clear()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user