diff --git a/eventlet/__init__.py b/eventlet/__init__.py index 57bf891..d918a64 100644 --- a/eventlet/__init__.py +++ b/eventlet/__init__.py @@ -10,7 +10,6 @@ sleep = greenthread.sleep spawn = greenthread.spawn spawn_n = greenthread.spawn_n call_after_global = greenthread.call_after_global -call_after_local = greenthread.call_after_local TimeoutError = greenthread.TimeoutError exc_after = greenthread.exc_after with_timeout = greenthread.with_timeout diff --git a/eventlet/api.py b/eventlet/api.py index 1f31e4d..2a667f5 100644 --- a/eventlet/api.py +++ b/eventlet/api.py @@ -121,11 +121,7 @@ spawn = greenthread.spawn spawn_n = greenthread.spawn_n -def kill(g, *throw_args): - get_hub_().schedule_call_global(0, g.throw, *throw_args) - if getcurrent() is not get_hub_().greenlet: - sleep(0) - +kill = greenthread.kill call_after = greenthread.call_after call_after_local = greenthread.call_after_local diff --git a/eventlet/greenthread.py b/eventlet/greenthread.py index 9fb27d6..146115c 100644 --- a/eventlet/greenthread.py +++ b/eventlet/greenthread.py @@ -8,6 +8,15 @@ __all__ = ['getcurrent', 'sleep', 'spawn', 'spawn_n', 'call_after_global', 'call getcurrent = greenlet.getcurrent +def kill(g, *throw_args): + """Terminates the target greenthread by raising an exception into it. + By default, this exception is GreenletExit, but a specific exception + may be specified in the *throw_args*. + """ + get_hub_().schedule_call_global(0, g.throw, *throw_args) + if getcurrent() is not get_hub_().greenlet: + sleep(0) + def sleep(seconds=0): """Yield control to another eligible coroutine until at least *seconds* have elapsed.