diff options
author | Michele Simionato <michele.simionato@gmail.com> | 2017-07-23 17:22:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-23 17:22:43 +0200 |
commit | 00584a5550de21c1af952c141a6bc272d6020035 (patch) | |
tree | 4532907d559ca1bf9bab22e924d77594236eebc9 /docs/tests.documentation.rst | |
parent | a4b6dc28a709c98f071c8061429840ac371d70a1 (diff) | |
parent | 15d908b3ce3db5607c75f7dff052b1541f73f534 (diff) | |
download | python-decorator-git-4.1.2.tar.gz |
Merge pull request #43 from micheles/coro-signaturerelease-4.1.24.1.2
Now the coroutine signature is determined by the caller
Diffstat (limited to 'docs/tests.documentation.rst')
-rw-r--r-- | docs/tests.documentation.rst | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/docs/tests.documentation.rst b/docs/tests.documentation.rst index d05172f..f77cb10 100644 --- a/docs/tests.documentation.rst +++ b/docs/tests.documentation.rst @@ -3,9 +3,9 @@ The ``decorator`` module :Author: Michele Simionato :E-mail: michele.simionato@gmail.com -:Version: 4.1.1 (2017-07-16) +:Version: 4.1.2 (2017-07-23) :Supports: Python 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6 -:Download page: http://pypi.python.org/pypi/decorator/4.1.1 +:Download page: http://pypi.python.org/pypi/decorator/4.1.2 :Installation: ``pip install decorator`` :License: BSD license @@ -966,8 +966,23 @@ with a particularly complex chain of coroutines. With a single line you can decorate the troubling coroutine function, understand what happens, fix the issue and then remove the decorator (or keep it if continuous monitoring of the coroutines makes sense). Notice that -`inspect.iscoroutinefunction(make_task)` -will return then right answer (i.e. `True`). +``inspect.iscoroutinefunction(make_task)`` +will return the right answer (i.e. ``True``). + +It is also possible to define decorators converting coroutine functions +into regular functions, such as the following: + +.. code-block:: python + + @decorator + def coro_to_func(coro, *args, **kw): + "Convert a coroutine into a function" + return get_event_loop().run_until_complete(coro(*args, **kw)) + +Notice the diffence: the caller in ``log_start_stop`` was a coroutine +function and the associate decorator was converting coroutines->coroutines; +the caller in ``coro_to_func`` is a regular function and converts +coroutines -> functions. Multiple dispatch ------------------------------------------- |