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:
Lonami Exo 2017-09-02 18:49:29 +02:00
parent 43b79c3d36
commit cc280a129d

View File

@ -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()