summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@master-shake.local>2006-01-18 22:55:03 -0800
committerRobey Pointer <robey@master-shake.local>2006-01-18 22:55:03 -0800
commit6a145dea09e8781711adcfe1c718ee5fd6c4f3fd (patch)
tree573fb0bec927f0ecefb84e3a7f6d9d1089cc2f4d
parentbe7d99886c2f6223d8f0899e4864c11f922dfde8 (diff)
[project @ robey@master-shake.local-20060119065503-341b1f0c0d161e22]
add Transport.atfork to handle the case where a forked child needs to cleanly dispose of a Transport where the socket is shared with its parent
-rw-r--r--paramiko/transport.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/paramiko/transport.py b/paramiko/transport.py
index abc1ea96..db3ada1f 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -325,6 +325,19 @@ class Transport (threading.Thread):
out += ' (connecting)'
out += '>'
return out
+
+ def atfork(self):
+ """
+ Terminate this Transport without closing the session. On posix
+ systems, if a Transport is open during process forking, both parent
+ and child will share the underlying socket, but only one process can
+ use the connection (without corrupting the session). Use this method
+ to clean up a Transport object without disrupting the other process.
+
+ @since: 1.6
+ """
+ self.sock.close()
+ self.close()
def get_security_options(self):
"""