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
This commit is contained in:
Robey Pointer 2006-01-18 22:55:03 -08:00
parent be7d99886c
commit 6a145dea09
1 changed files with 13 additions and 0 deletions

View File

@ -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):
"""