Commit 140355ba authored by Denis Bilenko's avatar Denis Bilenko

monkey: improve readability

parent 3fd5de56
......@@ -4,16 +4,19 @@ import sys
noisy = True
def patch_os():
from gevent.hub import fork
import os
os.fork = fork
def patch_time():
from gevent.hub import sleep
_time = __import__('time')
_time.sleep = sleep
def patch_thread():
from gevent import thread as green_thread
thread = __import__('thread')
......@@ -34,6 +37,7 @@ def patch_thread():
elif noisy:
sys.stderr.write("gevent.monkey's warning: '_threading_local' is already imported\n\n")
def patch_socket(dns=True):
from gevent.socket import socket, fromfd, wrap_ssl, socketpair
_socket = __import__('socket')
......@@ -44,6 +48,7 @@ def patch_socket(dns=True):
if dns:
patch_dns()
def patch_dns():
from gevent.socket import getaddrinfo, getnameinfo, gethostbyname
_socket = __import__('socket')
......@@ -79,7 +84,7 @@ def patch_all(socket=True, dns=True, time=True, select=True, thread=True, os=Tru
patch_ssl()
if __name__=='__main__':
if __name__ == '__main__':
modules = [x.replace('patch_', '') for x in globals().keys() if x.startswith('patch_') and x!='patch_all']
script_help = """gevent.monkey - monkey patch the standard modules to use gevent.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment