GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() by serhiy-storchaka · Pull Request #23554 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Nov 29, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue39529

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
Deprecate creating new event loop in asyncio.get_event_loop()
fe6d8db
@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement DO-NOT-MERGE labels Nov 29, 2020
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Nov 29, 2020
@bedevere-bot bedevere-bot added the awaiting core review label Nov 29, 2020
@serhiy-storchaka

serhiy-storchaka commented Nov 29, 2020

Copy link
Copy Markdown
Member Author

It is a draft. Tests which use asyncio.gather(), asyncio.as_completed(), etc in synchronous code should be rewritten to call them in coroutines, and purposed tests for warnings and errors should be added.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

asvetlov
asvetlov reviewed Nov 29, 2020
View reviewed changes

@asvetlov asvetlov left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/asyncio/tasks.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 10 commits December 5, 2020 23:00
@serhiy-storchaka
Test with real running loop.
1b57659
@serhiy-storchaka
Add more tests.
b6c9546
@serhiy-storchaka
Merge branch 'master' into asyncio-get_event_loop
d85dc62
@serhiy-storchaka
Revert some temporary changes.
f972573
@serhiy-storchaka
Refactor _ensure_future().
fba117d
@serhiy-storchaka
Merge branch 'master' into asyncio-get_event_loop
19ad168
@serhiy-storchaka
Rename tests.
fe6a4f6
@serhiy-storchaka
Simplify tests for gather() without arguments.
1eb0c5d
@serhiy-storchaka
Add documentation.
b717f71
@serhiy-storchaka
Rename some tests.
90e78bf
@serhiy-storchaka serhiy-storchaka removed the DO-NOT-MERGE label Dec 6, 2020
@serhiy-storchaka
serhiy-storchaka marked this pull request as ready for review December 6, 2020 18:26
@serhiy-storchaka
serhiy-storchaka requested review from 1st1 and rhettinger as code owners December 6, 2020 18:26
@serhiy-storchaka

serhiy-storchaka commented Dec 6, 2020

Copy link
Copy Markdown
Member Author

Ready for review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka commented Dec 6, 2020
View reviewed changes
Comment thread Lib/asyncio/tasks.py
loop = events.get_event_loop()
task = loop.create_task(coro_or_future)
if task._source_traceback:
del task._source_traceback[-1]

@serhiy-storchaka serhiy-storchaka Dec 6, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was removed because this code did not work as intented long time ago (if worked at all).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

asvetlov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/test/test_asyncio/test_tasks.py
res = loop.run_until_complete(asyncio.wait_for(coro(), timeout=None))
self.assertEqual(res, 'done')

def test_wait_for_with_global_loop(self):

@serhiy-storchaka serhiy-storchaka Dec 6, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is virtually a duplicate of the above test. Initially they were different by passing the loop argument or not, now it is removed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_asyncio/test_tasks.py
self.assertAlmostEqual(0.15, loop.time())
self.assertEqual(res, 42)

def test_wait_with_global_loop(self):

@serhiy-storchaka serhiy-storchaka Dec 6, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is virtually a duplicate of the above test. Initially they were different by passing the loop argument or not, now it is removed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_asyncio/test_tasks.py
self.assertEqual(y, 'b')
self.assertAlmostEqual(0.10, loop.time())

x = loop.run_until_complete(futs[1])

@serhiy-storchaka serhiy-storchaka Dec 6, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently two parts of the test was virtually duplicates. Added new tests (test_as_completed_coroutine_without_loop and below) which are essentially different.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka

serhiy-storchaka commented Dec 6, 2020

Copy link
Copy Markdown
Member Author

Please give attention to tests. This is the main part of the PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rhettinger
rhettinger removed their request for review December 19, 2020 04:30
@github-actions

github-actions Bot commented Jan 19, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jan 19, 2021
asvetlov
asvetlov approved these changes Apr 4, 2021
View reviewed changes

@asvetlov asvetlov left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please go ahead.
Sorry for the very long review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Apr 4, 2021
@serhiy-storchaka
Merge branch 'master' into asyncio-get_event_loop
eaa1cc1
@serhiy-storchaka
serhiy-storchaka merged commit 172c0f2 into python:master Apr 25, 2021
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 25, 2021
@serhiy-storchaka
serhiy-storchaka deleted the asyncio-get_event_loop branch April 25, 2021 10:40
@tirkarthi tirkarthi mentioned this pull request May 7, 2021
Python 3.10: Deprecation warnings regarding event loop spulec/freezegun#398
Open
@serhiy-storchaka serhiy-storchaka removed the stale Stale PR or inactive for long period of time. label Aug 31, 2021
@asvetlov asvetlov mentioned this pull request Jun 1, 2022
Deprecate get_event_loop() #83710
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@asvetlov asvetlov asvetlov approved these changes
@1st1 1st1 Awaiting requested review from 1st1

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@serhiy-storchaka @asvetlov @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.