Title: Add draining feature to asyncio.Queue by nhumrich · Pull Request #415 · python/asyncio · GitHub
Open Graph Title: Add draining feature to asyncio.Queue by nhumrich · Pull Request #415 · python/asyncio
X Title: Add draining feature to asyncio.Queue by nhumrich · Pull Request #415 · python/asyncio
Description: This feature adds the ability to drain a Queue. This is useful for cleanup steps, especially in the simple websocket case.
It adds the following things:
(coroutine) drain - waits until the queue is drained, errors on puts, errors on gets once queue is empty
drain_nowait
close - closes queue immediately, errors on all gets and puts
Imagine we have the following code:
import asyncio
q = asyncio.Queue()
async def wait_for_it():
while True:
t = await q.get()
q.task_done()
loop = asyncio.get_event_loop()
asyncio.ensure_future(wait_for_it())
try:
loop.run_forever()
except KeyboardInterrupt:
pass
This actually creates a lot of warnings/errors on shutdown, such as
Task was destroyed but it is pending!
task:
Open Graph Description: This feature adds the ability to drain a Queue. This is useful for cleanup steps, especially in the simple websocket case. It adds the following things: (coroutine) drain - waits until the queue i...
X Description: This feature adds the ability to drain a Queue. This is useful for cleanup steps, especially in the simple websocket case. It adds the following things: (coroutine) drain - waits until the queue i...
Opengraph URL: https://github.com/python/asyncio/pull/415
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7fb3d861-efb9-2d45-4595-32040b1b1c50 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A6DA:2A0782:30F53D:411BB1:6A52EDE8 |
| html-safe-nonce | d593ba4ea7066607bdd60664f6775aeaab1112a58b0b07750f7e27fc5d845b25 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkRBOjJBMDc4MjozMEY1M0Q6NDExQkIxOjZBNTJFREU4IiwidmlzaXRvcl9pZCI6IjYyMTYwODI3OTYwNzI1OTQ5MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 188d0cc9e42c24e0780fd21630ded0679e2317d26e7dae7efee7fe8685380c45 |
| hovercard-subject-tag | pull_request:84562513 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/asyncio/pull/415/files |
| twitter:image | https://avatars.githubusercontent.com/u/4661889?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4661889?s=400&v=4 |
| og:image:alt | This feature adds the ability to drain a Queue. This is useful for cleanup steps, especially in the simple websocket case. It adds the following things: (coroutine) drain - waits until the queue i... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/asyncio git https://github.com/python/asyncio.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 33739295 |
| octolytics-dimension-repository_nwo | python/asyncio |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33739295 |
| octolytics-dimension-repository_network_root_nwo | python/asyncio |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width