patch from sugarc0de to call Random.atfork() when starting up, so paramiko can be used in multiprocess code

This commit is contained in:
Robey Pointer 2011-05-21 19:29:38 -07:00
parent 22608540c3
commit 5d9eeaedcc
1 changed files with 2 additions and 5 deletions

View File

@ -45,11 +45,7 @@ from paramiko.server import ServerInterface
from paramiko.sftp_client import SFTPClient from paramiko.sftp_client import SFTPClient
from paramiko.ssh_exception import SSHException, BadAuthenticationType, ChannelException from paramiko.ssh_exception import SSHException, BadAuthenticationType, ChannelException
# these come from PyCrypt from Crypto import Random
# http://www.amk.ca/python/writing/pycrypt/
# i believe this on the standards track.
# PyCrypt compiled for Win32 can be downloaded from the HashTar homepage:
# http://nitace.bsd.uchicago.edu:8080/hashtar
from Crypto.Cipher import Blowfish, AES, DES3, ARC4 from Crypto.Cipher import Blowfish, AES, DES3, ARC4
from Crypto.Hash import SHA, MD5 from Crypto.Hash import SHA, MD5
try: try:
@ -456,6 +452,7 @@ class Transport (threading.Thread):
# synchronous, wait for a result # synchronous, wait for a result
self.completion_event = event = threading.Event() self.completion_event = event = threading.Event()
self.start() self.start()
Random.atfork()
while True: while True:
event.wait(0.1) event.wait(0.1)
if not self.active: if not self.active: