Skip to content
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

AsyncIO compatibility #4

Open
Gaboose opened this issue May 22, 2015 · 0 comments
Open

AsyncIO compatibility #4

Gaboose opened this issue May 22, 2015 · 0 comments

Comments

@Gaboose
Copy link

Gaboose commented May 22, 2015

Running an Owyl tree and something else concurrently in the same application is only possible with threading right now.

There is a safer and more modern alternative - asyncio, which is in the standard library. Lots of libraries are already compatible with it. This can also be a good time to upgrade Owyl to Python3.

It helps a lot that Asyncio's code patterns are very similar to Owyl's:

@owyl.parent_task
def sequence(*children, **kwargs):
    final_value = True
    for child in children:
        result = yield child(**kwargs)
        if not result and result is not None:
            final_value = False
            break
    yield final_value

@asyncio.coroutine
def sequence(*children, **kwargs):
    for coroutine in children:
        result = yield from coroutine(**kwargs)
        if not result:
            return False
    return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant