Title: Make get_event_loop() return the current loop if called from coroutines/callbacks by 1st1 · Pull Request #452 · python/asyncio · GitHub
Open Graph Title: Make get_event_loop() return the current loop if called from coroutines/callbacks by 1st1 · Pull Request #452 · python/asyncio
X Title: Make get_event_loop() return the current loop if called from coroutines/callbacks by 1st1 · Pull Request #452 · python/asyncio
Description: As discussed in [1] and [2], this PR makes asyncio.get_event_loop() to always return the currently running event loop when it is called from a coroutine. The patch adds two new functions: asyncio._set_current_loop() and asyncio._get_current_loop(). Both functions are thread-specific and are considered as low-level APIs, intended to be used by third-party loop implementations only. Even though they have a leading underscore, they will be documented as public asyncio API. loop.run_forever() is modified to call asyncio._set_current_loop() and asyncio._get_current_loop(). asyncio.get_event_loop() is modified to check if there is a current loop set by calling asyncio._get_current_loop(). If there is no current event loop, it returns the result of get_event_loop_policy().get_event_loop() (old behaviour). The biggest part of the patch is fixing unit tests: all test classes call super().setUp(). test_utils.TestCase.setUp patches asyncio._get_current_loop() to always return None. This change is to make sure that the loop is still being passed explicitly within asyncio. [1] PR: #355 [2] https://groups.google.com/d/msg/python-tulip/yF9C-rFpiKk/tk5oA3GLHAAJ
Open Graph Description: As discussed in [1] and [2], this PR makes asyncio.get_event_loop() to always return the currently running event loop when it is called from a coroutine. The patch adds two new functions: asyncio._...
X Description: As discussed in [1] and [2], this PR makes asyncio.get_event_loop() to always return the currently running event loop when it is called from a coroutine. The patch adds two new functions: asyncio._...
Opengraph URL: https://github.com/python/asyncio/pull/452
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c1116d54-390a-b781-ad32-28d1a3b73b97 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BCEC:304BF0:1F094E5:2B4B98A:6A5F3F8B |
| html-safe-nonce | d978cefb05e3919035f12218bc8aa81fd913a96fa57020850134d338e67925d3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0VDOjMwNEJGMDoxRjA5NEU1OjJCNEI5OEE6NkE1RjNGOEIiLCJ2aXNpdG9yX2lkIjoiNzExMjMxMjI2NDUyMDA1NjcxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8da6951b4a10c75aab127c9980f82e2a396b20c33336e6a095a5550ca5d4d3bf |
| hovercard-subject-tag | pull_request:92245081 |
| 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/452/files |
| twitter:image | https://avatars.githubusercontent.com/u/239003?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/239003?s=400&v=4 |
| og:image:alt | As discussed in [1] and [2], this PR makes asyncio.get_event_loop() to always return the currently running event loop when it is called from a coroutine. The patch adds two new functions: asyncio._... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ab2497d9345a59709926b385d88458fa5932c82ec066288448eb68b34cbcbbda |
| 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 | ba0ac57287507693938b0a2de45402a22cda0785 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width