8000 Question: How to relinquishing control to the event loop in Python 3.5 · Issue #284 · python/asyncio · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Question: How to relinquishing control to the event loop in Python 3.5 #284
Closed
@jashandeep-sohi

Description

@jashandeep-sohi

In Python < 3.5, you could do a yield or yield None in a coroutine to give control to the event loop.
In Python 3.5, it is invalid to yield in an async def coroutine. So, what's the proper way of relinquishing control to the event loop?

One pattern is:

class AsyncNone(object):
    __await__(self):
        yield

async def cor():
    for _ in range(100):
        await AsyncNone()

But this seems very hacky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0