Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 761538 - sys-apps/portage: [TRACKER] add asyncio.get_running_loop() and asyncio.run(coro) compat shims and migrate to them
Summary: sys-apps/portage: [TRACKER] add asyncio.get_running_loop() and asyncio.run(co...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: PullRequest
Depends on: 763339
Blocks: 758719
  Show dependency tree
 
Reported: 2020-12-24 23:42 UTC by Zac Medico
Modified: 2024-02-22 15:39 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2020-12-24 23:42:11 UTC
Since python3.7, the asyncio.get_running_loop() and asyncio.run(coro) functions are the preferred ways to access and run event loops. The asyncio.get_running_loop() function makes it possible to avoid passing around event loop instances in order to accommodate loops running in non-main threads (see the fix for bug 737698). For python3.6 compatibility, we can add shims for these functions in the portage.util.futures.asyncio module.
Comment 1 Zac Medico gentoo-dev 2021-09-22 04:38:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=631bedffe29124d693de3b539fc908d9feec1420

commit 631bedffe29124d693de3b539fc908d9feec1420
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2021-09-19 22:05:38 -0700
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2021-09-19 22:08:47 -0700

    _safe_loop: fix python3.10 DeprecationWarning
    
    DeprecationWarning: There is no current event loop
    
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/util/futures/_asyncio/__init__.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Comment 2 Larry the Git Cow gentoo-dev 2024-02-22 15:36:39 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=fbaaa4a733aaadc2744b656527756ac4e2b7ab58

commit fbaaa4a733aaadc2744b656527756ac4e2b7ab58
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-02-22 06:47:33 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-02-22 07:28:38 +0000

    socks5: Use real asyncio.run
    
    Use real asyncio.run to demonstrate that it is compatible with
    portage internals. Since the socks5 ProxyManager uses the
    process.spawn function, the internal _running_loop function
    needs to return the correct loop for use in the wait method of
    MultiprocessingProcess, or else it will lead to Future
    "attached to a different loop" errors.
    
    Bug: https://bugs.gentoo.org/761538
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/tests/util/test_socks5.py | 45 +++++++++++++++++++----------------
 lib/portage/util/socks5.py            | 30 ++++++++++++++++-------
 2 files changed, 46 insertions(+), 29 deletions(-)

https://gitweb.gentoo.org/proj/portage.git/commit/?id=d718cea94a180042b2285698b2c19113c5d25987

commit d718cea94a180042b2285698b2c19113c5d25987
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-02-22 06:41:49 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-02-22 07:28:38 +0000

    _get_running_loop: Support real asyncio.run
    
    When called via the real asyncio.run implementation, wrap
    the running asyncio loop. Otherwise, it's not possible to
    call portage libraries via the real asyncio.run without
    triggering Future "attached to a different loop" errors.
    
    Bug: https://bugs.gentoo.org/761538
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/util/futures/_asyncio/__init__.py | 28 +++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)