Skip to content

In model_worker /worker_generate API can blocked all request #2540

@lvxuan263

Description

@lvxuan263

When Request /worker_generate API and semaphore value bigger than 0, The program is blocked by worker.generate_gate(params) and not await acquire_worker_semaphore(). because worker.generate_gate(params) is runnning in main thread. other request will wait.

/worker_generate_stream doesn't blocked, maybe StreamResponse will start new subthread.

example:
first request: POST /worker_generate , Try to resp for as long as possible
second request: POST /worker_get_status, When the first request is not completed, the second request will be blocked.

solution:
I don't know much about python. Is it elegant in this way? Place generate_gate in non main thread

output = await asyncio.to_thread(worker.generate_gate, params)

thanks.

relate issue: #2285

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions