@@ -148,9 +148,6 @@ other coroutines::
148
148
* a *coroutine object *: an object returned by calling a
149
149
*coroutine function *.
150
150
151
- asyncio also supports legacy :ref: `generator-based
152
- <asyncio_generator_based_coro>` coroutines.
153
-
154
151
155
152
.. rubric :: Tasks
156
153
@@ -695,7 +692,7 @@ Running in Threads
695
692
696
693
This coroutine function is primarily intended to be used for executing
697
694
IO-bound functions/methods that would otherwise block the event loop if
698
- they were ran in the main thread. For example::
695
+ they were run in the main thread. For example::
699
696
700
697
def blocking_io():
701
698
print(f"start blocking_io at {time.strftime('%X')}")
@@ -766,7 +763,7 @@ Scheduling From Other Threads
766
763
767
764
try:
768
765
result = future.result(timeout)
769
- except asyncio .TimeoutError:
766
+ except concurrent.futures .TimeoutError:
770
767
print('The coroutine took too long, cancelling the task...')
771
768
future.cancel()
772
769
except Exception as exc:
@@ -1042,60 +1039,3 @@ Task Object
1042
1039
in the :func: `repr ` output of a task object.
1043
1040
1044
1041
.. versionadded :: 3.8
1045
-
1046
-
1047
- .. _asyncio_generator_based_coro :
1048
-
1049
- Generator-based Coroutines
1050
- ==========================
1051
-
1052
- .. note ::
1053
-
1054
- Support for generator-based coroutines is **deprecated ** and
1055
- is scheduled for removal in Python 3.10.
1056
-
1057
- Generator-based coroutines predate async/await syntax. They are
1058
- Python generators that use ``yield from `` expressions to await
1059
- on Futures and other coroutines.
1060
-
1061
- Generator-based coroutines should be decorated with
1062
- :func: `@asyncio.coroutine <asyncio.coroutine> `, although this is not
1063
- enforced.
1064
-
1065
-
1066
- .. decorator :: coroutine
1067
-
1068
- Decorator to mark generator-based coroutines.
1069
-
1070
- This decorator enables legacy generator-based coroutines to be
1071
- compatible with async/await code::
1072
-
1073
- @asyncio.coroutine
1074
- def old_style_coroutine():
1075
- yield from asyncio.sleep(1)
1076
-
1077
- async def main():
1078
- await old_style_coroutine()
1079
-
1080
- This decorator should not be used for :keyword: `async def `
1081
- coroutines.
1082
-
1083
- .. deprecated-removed :: 3.8 3.10
1084
-
1085
- Use :keyword: `async def ` instead.
1086
-
1087
- .. function :: iscoroutine(obj)
1088
-
1089
- Return ``True `` if *obj * is a :ref: `coroutine object <coroutine >`.
1090
-
1091
- This method is different from :func: `inspect.iscoroutine ` because
1092
- it returns ``True `` for generator-based coroutines.
1093
-
1094
- .. function :: iscoroutinefunction(func)
1095
-
1096
- Return ``True `` if *func * is a :ref: `coroutine function
1097
- <coroutine>`.
1098
-
1099
- This method is different from :func: `inspect.iscoroutinefunction `
1100
- because it returns ``True `` for generator-based coroutine functions
1101
- decorated with :func: `@coroutine <coroutine> `.
0 commit comments