Skip to content

remove ineffective ThreadPoolExecutor in infer_batch_process#1281

Merged
SWivid merged 1 commit intoSWivid:mainfrom
zhuxiaoxuhit:fix/remove-ineffective-threadpoolexecutor
Mar 24, 2026
Merged

remove ineffective ThreadPoolExecutor in infer_batch_process#1281
SWivid merged 1 commit intoSWivid:mainfrom
zhuxiaoxuhit:fix/remove-ineffective-threadpoolexecutor

Conversation

@zhuxiaoxuhit
Copy link
Copy Markdown
Contributor

process_batch is a generator function, so executor.submit(process_batch, gen_text) just creates a generator object in the thread without running any of the function body. all the actual inference runs in the main thread when next(result) is called. the thread pool brings no parallelism here.

also, the if result: check is always True since a generator object is always truthy, even when empty.

fix: replace the ThreadPoolExecutor loop with a plain sequential loop, which matches what actually happens. also removes the unused import.

process_batch is a generator function, so submitting it to a thread pool
only creates a generator object without running any inference code.
all actual work happens sequentially in the main thread when next() is called.
also removes the always-true 'if result:' guard on a generator object.
@SWivid SWivid merged commit 2414e3d into SWivid:main Mar 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants