Skip to content

Commit

Permalink
sshutils: shutdown all connections before exiting
Browse files Browse the repository at this point in the history
Register each SSHClient object's close() method with the atexit module.
This *should* close any open SSH connections on interpreter shutdown and
in theory prevent the dreaded "Exception in thread Thread-21 (most
likely raised during interpreter shutdown)" error with paramiko.

closes gh-135
  • Loading branch information
jtriley committed Dec 29, 2012
1 parent 43306ea commit ce6aaae
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions starcluster/sshutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import stat
import glob
import atexit
import string
import socket
import fnmatch
Expand Down Expand Up @@ -61,6 +62,7 @@ def __init__(self,
raise exception.SSHNoCredentialsError()
self._glob = SSHGlob(self)
self.__last_status = None
atexit.register(self.close)

def load_private_key(self, private_key, private_key_pass=None):
# Use Private Key.
Expand Down

0 comments on commit ce6aaae

Please sign in to comment.