def patch_socket(dns=True, aggressive=True):
 from gevent import socket
 if dns:
  items = socket.__implements__
 else:
  items = (set(socket.__implements__) - set(socket.__dns__))
 patch_module('socket', items=items)
 if aggressive:
  if ('ssl' not in socket.__implements__):
   remove_item(socket, 'ssl')

def patch_socket ( dns = True , aggressive = True ) : from gevent import socket if dns : items = socket . __implements__ else : items = ( set ( socket . __implements__ ) - set ( socket . __dns__ ) ) patch_module ( 'socket' , items = items ) if aggressive : if ( 'ssl' not in socket . __implements__ ) : remove_item ( socket , 'ssl' )
replace the standard socket object with gevents cooperative sockets .