gevent.monkey – Make the standard library cooperative

gevent.monkey.patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=True, ssl=True, httplib=False, subprocess=False, sys=False, aggressive=True, Event=False)

Do all of the default monkey patching (calls every other function in this module.

gevent.monkey.patch_socket(dns=True, aggressive=True)

Replace the standard socket object with gevent’s cooperative sockets.

If dns is true, also patch dns functions in socket.


Replace os.fork() with gevent.fork(). Does nothing if fork is not available.


Replace time.sleep() with gevent.sleep().


Replace with

If aggressive is true (the default), also remove other blocking functions the select.

gevent.monkey.patch_thread(threading=True, _threading_local=True, Event=False)

Replace the standard thread module to make it greenlet-based. If threading is true (the default), also patch threading. If _threading_local is true (the default), also patch _threading_local.local.

gevent.monkey.patch_sys(stdin=True, stdout=True, stderr=True)

Next page: gevent.core - event loop based on libev