pep 525: Make shutdown_asyncgens a coroutine
This commit is contained in:
parent
6855321295
commit
ad0a69aef1
|
@ -267,7 +267,7 @@ generators to be GCed.
|
||||||
|
|
||||||
To make sure that asyncio programs can finalize all scheduled
|
To make sure that asyncio programs can finalize all scheduled
|
||||||
asynchronous generators reliably, we propose to add a new event loop
|
asynchronous generators reliably, we propose to add a new event loop
|
||||||
method ``loop.shutdown_asyncgens(*, timeout=30)``. The method will
|
coroutine method ``loop.shutdown_asyncgens()``. The method will
|
||||||
schedule all currently open asynchronous generators to close with an
|
schedule all currently open asynchronous generators to close with an
|
||||||
``aclose()`` call.
|
``aclose()`` call.
|
||||||
|
|
||||||
|
@ -277,13 +277,12 @@ for the first time. The idea is that after requesting all asynchronous
|
||||||
generators to be shutdown, the program should not execute code that
|
generators to be shutdown, the program should not execute code that
|
||||||
iterates over new asynchronous generators.
|
iterates over new asynchronous generators.
|
||||||
|
|
||||||
An example of how ``shutdown_asyncgens`` should be used::
|
An example of how ``shutdown_asyncgens`` coroutine should be used::
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
# or loop.run_until_complete(...)
|
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||||
finally:
|
finally:
|
||||||
loop.shutdown_asyncgens()
|
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue