Moved kill into greenthread, out of api.
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user