Fix yield in async function python 3

Viewed 19

On old python this work but with new version doesn't work.

How to replace "yield from" in this function to work in python 3.9

async def receive_ast_info(request):
    logging.debug(
        "Ast info has been received from %s",
        request.remote
    )

    try:
        json = yield from request.json()
        json = json.pop()
    except Exception as exc:
        logging.error("Invalid data from Astra: %s", exc)
        return web.Response(text="ERROR: {}".format(exc),
                            status=400)

    if "channel_id" in json:
        request.app.channels[json["channel_id"]] = json
    elif "dvb_id" in json:
        request.app.adapters[json["dvb_id"]] = json

    return web.Response(text="OK")
0 Answers
Related