pep-0492: Fix example in Debugging Features section
This commit is contained in:
parent
4141a0644e
commit
a5bb069021
|
@ -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)``
|
||||
|
|
Loading…
Reference in New Issue