pep-0492: Fix example in Debugging Features section

This commit is contained in:
Yury Selivanov 2015-04-23 16:25:30 -04:00
parent 4141a0644e
commit a5bb069021
1 changed files with 4 additions and 4 deletions

View File

@ -466,18 +466,18 @@ Example::
await asyncio.sleep(1)
def async_debug_wrap(generator):
return asyncio.AsyncDebugWrapper(generator)
return asyncio.CoroWrapper(generator)
sys.set_coroutine_wrapper(async_debug_wrap)
debug_me() # <- this line will likely GC the coroutine object and
# trigger AsyncDebugWrapper's code.
# trigger asyncio.CoroWrapper's code.
assert isinstance(debug_me(), AsyncDebugWrapper)
assert isinstance(debug_me(), asyncio.CoroWrapper)
sys.set_coroutine_wrapper(None) # <- this unsets any
# previously set wrapper
assert not isinstance(debug_me(), AsyncDebugWrapper)
assert not isinstance(debug_me(), asyncio.CoroWrapper)
If ``sys.set_coroutine_wrapper()`` is called twice, the new wrapper
replaces the previous wrapper. ``sys.set_coroutine_wrapper(None)``