diff options
Diffstat (limited to 'lib/Python/Lib/OpenSSL/tsafe.py')
-rw-r--r-- | lib/Python/Lib/OpenSSL/tsafe.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Python/Lib/OpenSSL/tsafe.py b/lib/Python/Lib/OpenSSL/tsafe.py new file mode 100644 index 000000000..3a9c71035 --- /dev/null +++ b/lib/Python/Lib/OpenSSL/tsafe.py @@ -0,0 +1,28 @@ +from OpenSSL import SSL +_ssl = SSL +del SSL + +import threading +_RLock = threading.RLock +del threading + +class Connection: + def __init__(self, *args): + self._ssl_conn = _ssl.Connection(*args) + self._lock = _RLock() + + for f in ('get_context', 'pending', 'send', 'write', 'recv', 'read', + 'renegotiate', 'bind', 'listen', 'connect', 'accept', + 'setblocking', 'fileno', 'shutdown', 'close', 'get_cipher_list', + 'getpeername', 'getsockname', 'getsockopt', 'setsockopt', + 'makefile', 'get_app_data', 'set_app_data', 'state_string', + 'sock_shutdown', 'get_peer_certificate', 'get_peer_cert_chain', 'want_read', + 'want_write', 'set_connect_state', 'set_accept_state', + 'connect_ex', 'sendall'): + exec("""def %s(self, *args): + self._lock.acquire() + try: + return self._ssl_conn.%s(*args) + finally: + self._lock.release()\n""" % (f, f)) + |