Skip to main content

Transform your python code to use async/await (PEP 492)

Project description

PyPI python versions license

yield2await

Transform your python code from old syntax with yield from to use async/await (PEP 492).

Usage

$ pip install yield2await
$ yield2await <path> [-i <ignore-path>]

Before

@asyncio.coroutine
def handler(request):
    session = yield from get_session(request)
    session['last_visit'] = time.time()
    with (yield from self.dbengine) as conn:
        ret = yield from conn.execute(query)
        user = yield from ret.fetchone()
    return web.Response(body=b'OK')

After

async def handler(request):
    session = await get_session(request)
    session['last_visit'] = time.time()
    async with self.dbengine as conn:
        ret = await conn.execute(query)
        user = await ret.fetchone()
    return web.Response(body=b'OK')

Contribution

Feel free to contribute. Just do RP.

Caution

This is a very alpha, check the changes manually before commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yield2await-0.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file yield2await-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for yield2await-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e453a5ba05b3e5e7272e96d8708954acf159a1335c571d0d5aafb74057d72ae4
MD5 7ff6d1edab4765241b39f124f3bcae70
BLAKE2b-256 4b15117f577ff8c84ec9959f91a70671a3082fcb925ed3656ead29afe87b956b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page