Created
February 18, 2015 22:21
-
-
Save cbsmith/8da600d747158660444a to your computer and use it in GitHub Desktop.
monkey patch all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def 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.""" | |
# order is important | |
if os: | |
patch_os() | |
if time: | |
patch_time() | |
if thread: | |
patch_thread(Event=Event) | |
# sys must be patched after thread. in other cases threading._shutdown will be | |
# initiated to _MainThread with real thread ident | |
if sys: | |
patch_sys() | |
if socket: | |
patch_socket(dns=dns, aggressive=aggressive) | |
if select: | |
patch_select(aggressive=aggressive) | |
if ssl: | |
if version_info[:2] > (2, 5): | |
patch_ssl() | |
else: | |
try: | |
patch_ssl() | |
except ImportError: | |
pass # in Python 2.5, 'ssl' is a standalone package not included in stdlib | |
if httplib: | |
raise ValueError('gevent.httplib is no longer provided, httplib must be False') | |
if subprocess: | |
patch_subprocess() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment