<s> from OpenSSL import SSL <EOL> import traceback <EOL> import sys <EOL> def ssl_async_handshake ( sock , hub , next ) : <EOL> def shake ( ) : <EOL> try : <EOL> sock . do_handshake ( ) <EOL> except SSL . WantReadError : <EOL> hub . disable_write ( sock ) <EOL> except SSL . WantWriteError : <EOL> hub . enable_write ( sock ) <EOL> except SSL . WantX509LookupError : <EOL> pass <EOL> except Exception , e : <EOL> hub . unregister ( sock ) <EOL> next ( e ) <EOL> else : <EOL> hub . unregister ( sock ) <EOL> next ( ) <EOL> hub . register ( sock , shake , shake , shake ) <EOL> shake ( ) </s>
