make the transport a daemon thread since python 1.6 doesn't call the atexit handler correctly any more. also allow unicode as a hostname.

This commit is contained in:
Robey Pointer 2009-02-16 01:24:26 -08:00
parent 967b0011f0
commit 25417575ef
1 changed files with 2 additions and 1 deletions

View File

@ -266,7 +266,7 @@ class Transport (threading.Thread):
@param sock: a socket or socket-like object to create the session over. @param sock: a socket or socket-like object to create the session over.
@type sock: socket @type sock: socket
""" """
if type(sock) is str: if isinstance(sock, (str, unicode)):
# convert "host:port" into (host, port) # convert "host:port" into (host, port)
hl = sock.split(':', 1) hl = sock.split(':', 1)
if len(hl) == 1: if len(hl) == 1:
@ -280,6 +280,7 @@ class Transport (threading.Thread):
sock.connect((hostname, port)) sock.connect((hostname, port))
# okay, normal socket-ish flow here... # okay, normal socket-ish flow here...
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.setDaemon(True)
self.randpool = randpool self.randpool = randpool
self.sock = sock self.sock = sock
# Python < 2.3 doesn't have the settimeout method - RogerB # Python < 2.3 doesn't have the settimeout method - RogerB