From b0ae4f81c63984fc1938c86c03bb4048d634291a Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Wed, 24 Feb 2010 23:27:45 -0800 Subject: [PATCH] Much easier to just use the blanket defaults. :) --- eventlet/patcher.py | 9 +++++++++ tests/stdlib/test_socket_ssl.py | 14 +++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/eventlet/patcher.py b/eventlet/patcher.py index 4b33ae6..1383d87 100644 --- a/eventlet/patcher.py +++ b/eventlet/patcher.py @@ -81,6 +81,15 @@ def import_patched(module_name, *additional_modules, **kw_additional_modules): def patch_function(func, *additional_modules): """Huge hack here -- patches the specified modules for the duration of the function call.""" + if not additional_modules: + # supply some defaults + additional_modules = ( + _green_os_modules() + + _green_select_modules() + + _green_socket_modules() + + _green_thread_modules() + + _green_time_modules()) + def patched(*args, **kw): saved = {} for name, mod in additional_modules: diff --git a/tests/stdlib/test_socket_ssl.py b/tests/stdlib/test_socket_ssl.py index d418e1a..72a1d7b 100644 --- a/tests/stdlib/test_socket_ssl.py +++ b/tests/stdlib/test_socket_ssl.py @@ -2,8 +2,6 @@ from eventlet import patcher from eventlet.green import socket -from eventlet.green import urllib -from eventlet.green import threading # enable network resource import test.test_support @@ -21,16 +19,10 @@ try: except AttributeError: raise ImportError("Socket module doesn't support ssl") -patcher.inject('test.test_socket_ssl', - globals(), - ('socket', socket), - ('urllib', urllib), - ('threading', threading)) +patcher.inject('test.test_socket_ssl', globals()) -test_basic = patcher.patch_function(test_basic, - ('urllib', urllib)) -test_rude_shutdown = patcher.patch_function(test_rude_shutdown, - ('threading', threading)) +test_basic = patcher.patch_function(test_basic) +test_rude_shutdown = patcher.patch_function(test_rude_shutdown) def test_main(): if not hasattr(socket, "ssl"):