Skip to content

Commit

Permalink
Remove return bool from Channel.close() (#3403)
Browse files Browse the repository at this point in the history
Theres was no defined meaning to the return bool either in the code
or in the human text:

- no code calls close to give an example of interpretation

- it's not success/fail because local channel returns False
to indicate that it didn't need to do anything, not that there
was a failure.

Other .close() style methods return None and raise an exception
if there is a problem. This PR pushes Channel.close() in this
direction.

A separate PR will actually invoke this .close() method.
  • Loading branch information
benclifford committed May 16, 2024
1 parent e55ed98 commit 441a369
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
11 changes: 2 additions & 9 deletions parsl/channels/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,8 @@ def pull_file(self, remote_source: str, local_dir: str) -> str:
pass

@abstractmethod
def close(self) -> bool:
''' Closes the channel. Clean out any auth credentials.
Args:
None
Returns:
Bool
def close(self) -> None:
''' Closes the channel.
'''
pass

Expand Down
9 changes: 3 additions & 6 deletions parsl/channels/local/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,10 @@ def push_file(self, source, dest_dir):
def pull_file(self, remote_source, local_dir):
return self.push_file(remote_source, local_dir)

def close(self):
''' There's nothing to close here, and this really doesn't do anything
Returns:
- False, because it really did not "close" this channel.
def close(self) -> None:
''' There's nothing to close here, and so this doesn't do anything
'''
return False
pass

def isdir(self, path):
"""Return true if the path refers to an existing directory.
Expand Down
4 changes: 2 additions & 2 deletions parsl/channels/oauth_ssh/oauth_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ def execute_wait(self, cmd, walltime=60, envs={}):

return exit_status, stdout, stderr

def close(self):
return self.transport.close()
def close(self) -> None:
self.transport.close()
4 changes: 2 additions & 2 deletions parsl/channels/ssh/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def pull_file(self, remote_source, local_dir):

return local_dest

def close(self):
def close(self) -> None:
if self._is_connected():
return self.ssh_client.close()
self.ssh_client.close()

def isdir(self, path):
"""Return true if the path refers to an existing directory.
Expand Down

0 comments on commit 441a369

Please sign in to comment.