Turn timeout into a property instead leaving it as a parameter

This commit is contained in:
Lonami Exo
2017-06-22 11:43:42 +02:00
parent 52a42661ee
commit e4fbd87c75
5 changed files with 97 additions and 67 deletions

View File

@@ -80,7 +80,7 @@ class TcpClient:
# Set the starting time so we can
# calculate whether the timeout should fire
start_time = datetime.now() if timeout else None
start_time = datetime.now() if timeout is not None else None
with BufferedWriter(BytesIO(), buffer_size=size) as buffer:
bytes_left = size
@@ -104,7 +104,7 @@ class TcpClient:
time.sleep(self.delay)
# Check if the timeout finished
if timeout:
if timeout is not None:
time_passed = datetime.now() - start_time
if time_passed > timeout:
raise TimeoutError(