How to use the aiojobs.aiohttp.spawn function in aiojobs

To help you get started, we’ve selected a few aiojobs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github virtool / virtool / virtool / references / api.py View on Github external
}

    process = await virtool.processes.db.register(db, "update_remote_reference", context=context)

    release, update_subdocument = await virtool.references.db.update(
        req.app,
        created_at,
        process["id"],
        ref_id,
        release,
        user_id
    )

    p = virtool.references.db.UpdateRemoteReferenceProcess(req.app, process["id"])

    await aiojobs.aiohttp.spawn(req, p.run())

    return json_response(update_subdocument, status=201)
github virtool / virtool / virtool / hmm / api.py View on Github external
})

    release = document.get("release", None)

    if release is None:
        return bad_request("Target release does not exist")

    update = virtool.github.create_update_subdocument(release, False, user_id)

    await db.status.update_one({"_id": "hmm"}, {
        "$push": {
            "updates": update
        }
    })

    await aiojobs.aiohttp.spawn(req, virtool.hmm.db.install(
        req.app,
        process["id"],
        release,
        user_id
    ))

    return json_response(update)
github aio-libs / aiozipkin / examples / queue / backend.py View on Github external
async def handler(request):
    message = await request.json()
    tracer = az.get_tracer(request.app)
    for _ in range(5):
        asyncio.ensure_future(
            aiojobs.aiohttp.spawn(request, consume_message(message, tracer))
        )

    return web.Response(text='ok')
github virtool / virtool / virtool / software / api.py View on Github external
await db.status.update_one({"_id": "software"}, {
        "$set": {
            "process": process,
            "updating": True
        }
    })

    update = virtool.github.create_update_subdocument(
        latest_release,
        False,
        req["client"].user_id,
        virtool.utils.timestamp()
    )

    await aiojobs.aiohttp.spawn(req, virtool.software.db.install(
        req.app,
        latest_release,
        process["id"]
    ))

    return json_response(update)
github virtool / virtool / virtool / references / api.py View on Github external
document = await virtool.references.db.create_remote(
            db,
            settings,
            release,
            remote_from,
            user_id
        )

        process = await virtool.processes.db.register(db, "remote_reference")

        document["process"] = {
            "id": process["id"]
        }

        await aiojobs.aiohttp.spawn(req, virtool.references.db.finish_remote(
            req.app,
            release,
            document["_id"],
            document["created_at"],
            process["id"],
            user_id
        ))

    else:
        document = await virtool.references.db.create_document(
            db,
            settings,
            data["name"],
            data["organism"],
            data["description"],
            data["data_type"],
github virtool / virtool / virtool / analyses / api.py View on Github external
return insufficient_rights()

    # Start a BLAST at NCBI with the specified sequence. Return a RID that identifies the BLAST run.
    rid, _ = await virtool.bio.initialize_ncbi_blast(req.app["settings"], sequence)

    blast_data, document = await virtool.analyses.db.update_nuvs_blast(
        db,
        settings,
        analysis_id,
        sequence_index,
        rid
    )

    # Wait on BLAST request as a Task until the it completes on NCBI. At that point the sequence in the DB will be
    # updated with the BLAST result.
    await aiojobs.aiohttp.spawn(req, virtool.bio.wait_for_blast_result(
        req.app,
        analysis_id,
        sequence_index,
        rid
    ))

    headers = {
        "Location": f"/api/analyses/{analysis_id}/{sequence_index}/blast"
    }

    return json_response(blast_data, headers=headers, status=201)