Title: Asyncio example is completely wrong, update · Issue #988 · sendgrid/sendgrid-python · GitHub
Open Graph Title: Asyncio example is completely wrong, update · Issue #988 · sendgrid/sendgrid-python
X Title: Asyncio example is completely wrong, update · Issue #988 · sendgrid/sendgrid-python
Description: Issue Summary I'm talking about this example https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/asynchronous_mail_send.md Steps to Reproduce Using asyncio is more than just putting async in front of the function doing the ht...
Open Graph Description: Issue Summary I'm talking about this example https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/asynchronous_mail_send.md Steps to Reproduce Using asyncio is more than just putting asy...
X Description: Issue Summary I'm talking about this example https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/asynchronous_mail_send.md Steps to Reproduce Using asyncio is more than just putting...
Opengraph URL: https://github.com/sendgrid/sendgrid-python/issues/988
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Asyncio example is completely wrong, update","articleBody":"### Issue Summary\r\nI'm talking about this example https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/asynchronous_mail_send.md\r\n\r\n### Steps to Reproduce\r\nUsing asyncio is more than just putting `async` in front of the function doing the http request. In fact this is the completely wrong way to use `asyncio` and will actually destroys performance as this blocks the event loop from doing **any other work** while the http request is being made.\r\n\r\nTo use asyncio correctly the tcp socket sending the data must be using asyncio and one of the low level asyncio socket functions. https://docs.python.org/3/library/asyncio-stream.html These are awaited, allowing the event loop to do other work.\r\n\r\nWhat you have suggested is EXTREMELY bad practice and will stall the servers of anyone who uses it. This is why you can't use `requests` or `urllib` with asyncio. You have to use something like [aiohttp](https://docs.aiohttp.org/en/stable/).\r\n\r\nThe right way to use asyncio with your library is to run it in a [thread pool executor](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor) so that the blocking IO stays off the main thread.\r\n\r\nYou would be better off deleting that example than keeping it in it's current form.","author":{"url":"https://github.com/agronick","@type":"Person","name":"agronick"},"datePublished":"2021-04-26T18:41:08Z","url":"https://github.com/sendgrid/sendgrid-python/issues/988"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f60c3c42-3667-0859-e7a3-57933cff45d8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A766:3A73AA:275B5E0:31F06C2:6B01D11B |
| html-safe-nonce | ce73b06002855b6a33782f8bbad71da7acdfc15169d36944cfd989ed9c4c70e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzY2OjNBNzNBQToyNzVCNUUwOjMxRjA2QzI6NkIwMUQxMUIiLCJ2aXNpdG9yX2lkIjoiNDc1NjAxNjQ3NjM1NDM2Nzc3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7b7b53b3bbfd29b68f0fdc0cbd2e7e7bb48ebaf77a080aafd8b2961738be2868 |
| hovercard-subject-tag | issue:868009281 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/sendgrid/sendgrid-python/988/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0264c849de21dc207fd74e12d9ef6aadd6f74efb75ee32a78d6338555a27f8a9/sendgrid/sendgrid-python/issues/988 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0264c849de21dc207fd74e12d9ef6aadd6f74efb75ee32a78d6338555a27f8a9/sendgrid/sendgrid-python/issues/988 |
| og:image:alt | Issue Summary I'm talking about this example https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/asynchronous_mail_send.md Steps to Reproduce Using asyncio is more than just putting asy... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | agronick |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/sendgrid/sendgrid-python git https://github.com/sendgrid/sendgrid-python.git |
| octolytics-dimension-user_id | 181234 |
| octolytics-dimension-user_login | sendgrid |
| octolytics-dimension-repository_id | 3546794 |
| octolytics-dimension-repository_nwo | sendgrid/sendgrid-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3546794 |
| octolytics-dimension-repository_network_root_nwo | sendgrid/sendgrid-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width