Skip to content

Commit

Permalink
Incorrect timeout evaluation in long_running
Browse files Browse the repository at this point in the history
Unit testing indicated that `if not timeout ...` was not
getting evaluated correctly. This patch switches to checking
if timeout is not None ...

Signed-off-by: Pragadeeswaran Sathyanarayanan <[email protected]>
  • Loading branch information
psathyan committed Jul 17, 2024
1 parent 93d0509 commit c05bc36
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ceph/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,8 +1524,6 @@ def long_running(self, **kw):
channel.set_combine_stderr(True)
channel.exec_command(cmd)

# Channel timeout is per operation. Waiting for a specified duration or
# command execution completion.
if timeout:
_end_time = datetime.datetime.now() + datetime.timedelta(
seconds=timeout
Expand All @@ -1543,7 +1541,8 @@ def long_running(self, **kw):

data = channel.recv(1024)

if not timeout and _end_time > datetime.datetime.now():
# time check - raise exception when exceeded.
if timeout is not None and _end_time > datetime.datetime.now():
channel.close()
raise SocketTimeoutException(
f"{cmd} failed to complete within {timeout}s"
Expand Down

0 comments on commit c05bc36

Please sign in to comment.