(sock, on_done=None, on_error=None, extra_args=None)
SSL Async Handshake

    :param on_done: Function called when handshake is complete
    :type on_done: :function:

    :param on_error: Function called when handshake errored
    :type on_error: :function:
SSL Async Handshake
SSL Async Handshake
def do_handshake(sock, on_done=None, on_error=None, extra_args=None):
    """SSL Async Handshake

    :param on_done: Function called when handshake is complete
    :type on_done: :function:

    :param on_error: Function called when handshake errored
    :type on_error: :function:
    """

    extra_args = extra_args or ()

    while True:
        try:
            sock.do_handshake()
            break
        except SSLError as err:
            if err.args[0] == SSL_ERROR_WANT_READ:
                select.select([sock], [], [])
            elif err.args[0] == SSL_ERROR_WANT_WRITE:
                select.select([], [sock], [])
            else:
                callable(on_error) and on_error(sock, err)
                return

        yield

    callable(on_done) and on_done(sock, *extra_args)
def do_handshake ( sock , on_done = None , on_error = None , extra_args = None ) : extra_args = extra_args or ( ) while True : try : sock . do_handshake ( ) break except SSLError as err : if err . args [ 0 ] == SSL_ERROR_WANT_READ : select . select ( [ sock ] , [ ] , [ ] ) elif err . args [ 0 ] == SSL_ERROR_WANT_WRITE : select . select ( [ ] , [ sock ] , [ ] ) else : callable ( on_error ) and on_error ( sock , err ) return yield callable ( on_done ) and on_done ( sock , * extra_args )