Skip to content

fastapi-streaming-example - perhaps creating a new thread can be avoided & instead use create_task #93

@ksachdeva

Description

@ksachdeva

Expected Behaviour

minimize or eliminate thread creation if the entire stack is async

Current Behaviour

https://github.com/awslabs/multi-agent-orchestrator/blob/da9563fe9e87343fcda8abe6303b1e1d4f36c943/examples/fast-api-streaming/main.py#L119

Above line will spawn a new thread for every request.

Code snippet

https://github.com/awslabs/multi-agent-orchestrator/blob/da9563fe9e87343fcda8abe6303b1e1d4f36c943/examples/fast-api-streaming/main.py#L119

Possible Solution

What would be an issue if you do the following -

asyncio.create_task(start_generation(query, user_id, session_id, streamer_queue))

instead of spawning a new thread

Steps to Reproduce

See - https://github.com/awslabs/multi-agent-orchestrator/blob/da9563fe9e87343fcda8abe6303b1e1d4f36c943/examples/fast-api-streaming/main.py#L119

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions