Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 660426

Summary: sys-apps/portage: make asynchronous code use coroutines to avoid callbacks when possible
Product: Portage Development Reporter: Zac Medico <zmedico>
Component: CoreAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal Keywords: InVCS
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 658182, 659322    

Description Zac Medico gentoo-dev 2018-07-05 04:31:57 UTC
I've created a small python2.x compatible framework that implements coroutines using generators that yield Futures. I will post the code shortly. I'd like to use this to avoid using asynchronous callbacks when possible.
Comment 2 Larry the Git Cow gentoo-dev 2018-07-11 08:11:57 UTC
The bug has been referenced in the following commit(s):

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

commit edba848a013e1797faeacc1911a5e6571fca3ca7
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2018-07-05 04:44:42 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2018-07-11 07:40:59 +0000

    Add python2 compatible coroutine support (bug 660426)
    
    For readability, it's desirable to make asynchronous code use
    coroutines to avoid callbacks when possible. For python2 compatibility,
    generators that yield Futures can be used to implement coroutines.
    
    Add a compat_coroutine module which provides a @coroutine decorator
    and a coroutine_return function that can be used to return a value
    from a generator. The decorated function returns a Future which is
    done when the generator is exhausted. Usage is very similar to asyncio
    coroutine usage in python3.4 (see unit tests).
    
    Bug: https://bugs.gentoo.org/660426

 .../tests/util/futures/test_compat_coroutine.py    | 159 +++++++++++++++++++++
 pym/portage/util/futures/compat_coroutine.py       | 112 +++++++++++++++
 2 files changed, 271 insertions(+)