Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 660426 - sys-apps/portage: make asynchronous code use coroutines to avoid callbacks when possible
Summary: sys-apps/portage: make asynchronous code use coroutines to avoid callbacks wh...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 658182 659322
  Show dependency tree
 
Reported: 2018-07-05 04:31 UTC by Zac Medico
Modified: 2018-10-12 19:32 UTC (History)
0 users

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 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(+)