Commit 0ebd48e3 authored by Denis Bilenko's avatar Denis Bilenko

monkey: avoid spurious warnings

parent a58a8202
...@@ -15,23 +15,24 @@ def patch_time(): ...@@ -15,23 +15,24 @@ def patch_time():
_time.sleep = sleep _time.sleep = sleep
def patch_thread(): def patch_thread():
if noisy and 'threading' in sys.modules:
sys.stderr.write("gevent.monkey's warning: 'threading' is already imported\n\n")
from gevent import thread as green_thread from gevent import thread as green_thread
thread = __import__('thread') thread = __import__('thread')
thread.get_ident = green_thread.get_ident if thread.exit is not green_thread.exit:
thread.start_new_thread = green_thread.start_new_thread thread.get_ident = green_thread.get_ident
thread.LockType = green_thread.LockType thread.start_new_thread = green_thread.start_new_thread
thread.allocate_lock = green_thread.allocate_lock thread.LockType = green_thread.LockType
thread.exit = green_thread.exit thread.allocate_lock = green_thread.allocate_lock
if hasattr(green_thread, 'stack_size'): thread.exit = green_thread.exit
thread.stack_size = green_thread.stack_size if hasattr(green_thread, 'stack_size'):
# built-in thread._local object won't work as greenlet-local thread.stack_size = green_thread.stack_size
if '_threading_local' not in sys.modules: if noisy and 'threading' in sys.modules:
import _threading_local sys.stderr.write("gevent.monkey's warning: 'threading' is already imported\n\n")
thread._local = _threading_local.local # built-in thread._local object won't work as greenlet-local
elif noisy: if '_threading_local' not in sys.modules:
sys.stderr.write("gevent.monkey's warning: '_threading_local' is already imported\n\n") import _threading_local
thread._local = _threading_local.local
elif noisy:
sys.stderr.write("gevent.monkey's warning: '_threading_local' is already imported\n\n")
def patch_socket(dns=True): def patch_socket(dns=True):
from gevent.socket import GreenSocket, fromfd, wrap_ssl, socketpair from gevent.socket import GreenSocket, fromfd, wrap_ssl, socketpair
......
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