[Python-checkins] peps: pep-0492: rename set_async_wrapper -> set_coroutine_wrapper

yury.selivanov python-checkins at python.org
Fri Apr 17 23:14:51 CEST 2015


https://hg.python.org/peps/rev/699ef9a26ef9
changeset:   5763:699ef9a26ef9
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Fri Apr 17 17:14:47 2015 -0400
summary:
  pep-0492: rename set_async_wrapper -> set_coroutine_wrapper

files:
  pep-0492.txt |  16 +++++++---------
  1 files changed, 7 insertions(+), 9 deletions(-)


diff --git a/pep-0492.txt b/pep-0492.txt
--- a/pep-0492.txt
+++ b/pep-0492.txt
@@ -439,7 +439,7 @@
 different debug facility, has no impact on ``@coroutine`` decorator's behavior.
 
 With this proposal, coroutines is a native, distinct from generators,
-concept.  A new method ``set_async_wrapper`` is added to the ``sys`` module,
+concept.  A new method ``set_coroutine_wrapper`` is added to the ``sys`` module,
 with which frameworks can provide advanced debugging facilities.
 
 It is also important to make coroutines as fast and efficient as possible,
@@ -453,18 +453,19 @@
     def async_debug_wrap(generator):
         return asyncio.AsyncDebugWrapper(generator)
 
-    sys.set_async_wrapper(async_debug_wrap)
+    sys.set_coroutine_wrapper(async_debug_wrap)
 
     debug_me()  # <- this line will likely GC the coroutine object and
                 # trigger AsyncDebugWrapper's code.
 
     assert isinstance(debug_me(), AsyncDebugWrapper)
 
-    sys.set_async_wrapper(None)   # <- this unsets any previously set wrapper
+    sys.set_coroutine_wrapper(None) # <- this unsets any
+                                    #    previously set wrapper
     assert not isinstance(debug_me(), AsyncDebugWrapper)
 
-If ``sys.set_async_wrapper()`` is called twice, the new wrapper replaces the
-previous wrapper.  ``sys.set_async_wrapper(None)`` unsets the wrapper.
+If ``sys.set_coroutine_wrapper()`` is called twice, the new wrapper replaces the
+previous wrapper.  ``sys.set_coroutine_wrapper(None)`` unsets the wrapper.
 
 
 Glossary
@@ -915,7 +916,7 @@
 5. New AST nodes: ``AsyncFor``, ``AsyncWith``, ``Await``; ``FunctionDef`` AST
    node got a new argument ``is_async``.
 
-6. New functions: ``sys.set_async_wrapper(callback)`` and
+6. New functions: ``sys.set_coroutine_wrapper(callback)`` and
    ``types.async_def(gen)``.
 
 7. New ``CO_ASYNC`` bit flag for code objects.
@@ -936,12 +937,10 @@
 
     import asyncio
 
-
     async def echo_server():
         print('Serving on localhost:8000')
         await asyncio.start_server(handle_connection, 'localhost', 8000)
 
-
     async def handle_connection(reader, writer):
         print('New connection...')
 
@@ -954,7 +953,6 @@
             print('Sending {:.10}... back'.format(repr(data)))
             writer.write(data)
 
-
     loop = asyncio.get_event_loop()
     loop.run_until_complete(echo_server())
     try:

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list