-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update async samples to use asyncio.run instead of loop #21207
Comments
I have a question about this issue. As asyncio.get_event_loop is deprecated, we can suggest several methods. The first method, this is the lower-level method. loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(...) The second method, this method was added in Python 3.7. The reference document officially recommends the following method. loop = asyncio.get_running_loop()
loop.run_until_complete(...) Last method, this method was also added in Python 3.7. asyncio.run(...) In the sample, the |
Hi @Codejune , First on the Python versions: the baseline we support today is 3.6, that is going EOL this December 2021. We are not sure yet if we will deprecate 3.6 support immediately at its EOL, but soon in 2022 we will stop supporting 3.6 completely anyway. Which will make 3.7 the new baseline. There are no "lower users", since we stopped supporting 3.5 and below for a few months already. The documented way in the Python doc today is
Following the recommendation of Python documentation do not prevent you to use |
# Description As #21207 mentions, some samples are using a loop variable for simple callbacks when this can be done by using the new run method of asyncio. This PR remedies the issue for the monitor library. # All SDK Contribution checklist: - [x] **The pull request does not introduce [breaking changes]** - [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### [Testing Guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md##building-and-testing) - [x] Pull request includes test coverage for the included changes.
# Description As Azure#21207 mentions, some samples are using a loop variable for simple callbacks when this can be done by using the new run method of asyncio. This PR remedies the issue for the monitor library. # All SDK Contribution checklist: - [x] **The pull request does not introduce [breaking changes]** - [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### [Testing Guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md##building-and-testing) - [x] Pull request includes test coverage for the included changes.
asyncio.get_event_loop
is deprecated, a deprecation warning will be emitted if there is no running event loop. (For more context on the deprecation, please check doc: https://docs.python.org/3/library/asyncio-eventloop.html#event-loop)asyncio.run
instead of loop as suggested by the Python community:cc: @lmazuel
The text was updated successfully, but these errors were encountered: