Initial port of 3709d2e02bf67ccc272e1f2311e5db125a922ba0 from 'ssh'
Re #17
This commit is contained in:
parent
edddc61fb5
commit
8f9b37add4
|
@ -1505,12 +1505,17 @@ class Transport (threading.Thread):
|
|||
# indefinitely, creating a GC cycle and not letting Transport ever be
|
||||
# GC'd. it's a bug in Thread.)
|
||||
|
||||
# Hold reference to 'sys' so we can test sys.modules to detect
|
||||
# interpreter shutdown.
|
||||
self.sys = sys
|
||||
|
||||
# active=True occurs before the thread is launched, to avoid a race
|
||||
_active_threads.append(self)
|
||||
if self.server_mode:
|
||||
self._log(DEBUG, 'starting thread (server mode): %s' % hex(long(id(self)) & 0xffffffffL))
|
||||
else:
|
||||
self._log(DEBUG, 'starting thread (client mode): %s' % hex(long(id(self)) & 0xffffffffL))
|
||||
try:
|
||||
try:
|
||||
self.packetizer.write_all(self.local_version + '\r\n')
|
||||
self._check_banner()
|
||||
|
@ -1600,6 +1605,13 @@ class Transport (threading.Thread):
|
|||
finally:
|
||||
self.lock.release()
|
||||
self.sock.close()
|
||||
except:
|
||||
# Don't raise spurious 'NoneType has no attribute X' errors when we
|
||||
# wake up during interpreter shutdown. Or rather -- raise
|
||||
# everything *if* sys.modules (used as a convenient sentinel)
|
||||
# appears to still exist.
|
||||
if self.sys.modules is not None:
|
||||
raise
|
||||
|
||||
|
||||
### protocol stages
|
||||
|
|
Loading…
Reference in New Issue